Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

JNI_CreateJavaVM returns JNI_ERR

Thread view: 
dzikus_@vp.pl - 03 Nov 2006 16:42 GMT
Hello,
I have problem with following code:
  ...
  JNIEnv *env;
  JavaVM *jvm;
  JavaVMInitArgs vm_args;

  vm_args.version = JNI_VERSION_1_2;
  vm_args.options = NULL;
  vm_args.nOptions = 0;
  vm_args.ignoreUnrecognized = JNI_TRUE;
  res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
  ...

unfortunately JNI_CreateJavaVM returns -1 (JNI_ERR).

I tried on WinXP using jdk1.3.1_19 and VC++ 2005.
jvm.dll is copied from jdk1.3.1_19\jre\bin\classic\ to working path,
jdk1.3.1_19\include\ and jdk1.3.1_19\include\win32 are added to include
path
jdk1.3.1_19\lib\jvm.lib is included while linking program,

Do you have any idea what else should i check?

Regards
  Dominik
www.goryidoliny.freehost.pl
Chris Uppal - 03 Nov 2006 17:48 GMT
> jvm.dll is copied from jdk1.3.1_19\jre\bin\classic\ to working path,

You may have other problems, but that will cause JNI_CreateJavaVM() to fail all
by itself.  You have to ensure that your outer program is loading the JVM.DLL
from the right place, not move the DLL.

I prefer to use an explicit call to the Win32 LoadLibrary() function myself
(I've posted example code here before -- Google should find it).  Or you could
set the %Path% to include the directory containing the JVM.DLL -- that may
sound easier but is probably more messing around in the long run.

   -- chris
dzikus_@vp.pl - 06 Nov 2006 13:15 GMT
I thing proper jvm.dll is loaded , becouse:
1) I see it indebugger information about loaded dll's:
  ... Loaded 'C:\dschaefer\workspace\jni\jvm.dll', No symbols loaded
...
2) when I delete dll from project directory program does not run
anymore.

Has anybody any other ideas?

Regards
   Dominik

> > jvm.dll is copied from jdk1.3.1_19\jre\bin\classic\ to working path,
>
[quoted text clipped - 8 lines]
>
>     -- chris
Gordon Beaton - 06 Nov 2006 13:37 GMT
> I thing proper jvm.dll is loaded , becouse:
> 1) I see it indebugger information about loaded dll's:
[quoted text clipped - 4 lines]
>
> Has anybody any other ideas?

Yes. Listen to the advice you've been given. Do not move the jvm.dll
from the rest of the JVM. It is dependent on other files there.

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

dzikus_@vp.pl - 06 Nov 2006 14:21 GMT
> Do not move the jvm.dll from the rest of the JVM. It is dependent on other files there.

This was the cause of my problem.
I have added to the PATH environment variable path
c:\Java\jdk1.3.1_19\jre\bin\classic\
and now CreateJavaVM is working OK :)

Thanks a lot for help
Best regards
  Dominik


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.