problem linking java virtual machine...

E

enantiomer

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
 
O

Owen Jacobson

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,

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top