I am trying to get JNI to work from my C++ based application.
Starting from the very most basic, i am just trying to create an
instance of the JVM in my main program. Below is the code in main.
JavaVMOption options[1];
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
long status;
jclass cls;
jmethodID mid;
jobject obj;
options[0].optionString = "-Djava.class.path=.";
memset(&vm_args, 0, sizeof(vm_args));
vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 1;
vm_args.options = options;
status = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
I got the code from a website that had some examples. I added the
reference to the jni.h header and when i added the link to the
application within my VC++ 6.0 project with the path like
C:\j2sdk1.4.2_02\lib\jvm.lib. the problem i am noticing is that when i
try to run the application, I get an erro that says "This applicaiton
has failed to start because jvm.dll was not found..." I am assuming
that the jvm.lib file links to the jvm.dll file, but I am not sure
exactly how to make VC++ see this. Any ideas? Thanks,
Jonathan
Owen Jacobson - 12 Mar 2005 05:23 GMT
> I got the code from a website that had some examples. I added the
> reference to the jni.h header and when i added the link to the application
[quoted text clipped - 4 lines]
> jvm.lib file links to the jvm.dll file, but I am not sure exactly how to
> make VC++ see this. Any ideas? Thanks,
In order to run an application, all of its code must be visible. For
Windows DLLs, this means the DLL must be either in the same directory as
the executable, in the working directory, or somewhere on the PATH.