tags:

views:

223

answers:

1

My simple command line app:

int _tmain(int argc, _TCHAR* argv[])
{
 JavaVM *jvm;
 JNIEnv *env;
 JavaVMInitArgs vm_args;
 JavaVMOption options[1];
 options[0].optionString = "-Djava.class.path=."; //Path to the java source code
 vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
 vm_args.nOptions = 1;
 vm_args.options = options;
 vm_args.ignoreUnrecognized = 0;

 jint ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
 return 0;
}

gives me:

Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries

The breakpoint at "return 0" is never reached. jvm.dll resides in same directory as my command line app.

I don't get it what's wrong. Any Ideas? Thanx in advance

+2  A: 

I think that your problem is answered by this question in the Sun JNI FAQ.

Stephen C
Thank you very much! That was the issue. I looked by Dependency Walker and just copied it. Now added it to path and works. Stupid misleading error message.
Michael Bruckmeier
I don't get how this answer and your comment reply apply to the problem. Could you elaborate on the fix? What did you copy where? I don't see a "classic" dir in my jre or jdk's bin dir :-(
Wouter Lievens
@Wouter - the point is that you must not move the DDLs around. If you do, then the JVM gets confused, as the FAQ explained. (The actual layout of the JRE installation directory tree may have changed, which could be why you cannot see a "classic" directory. But the FAQ's key point remains valid: don't move the DLLs around.)
Stephen C