I'm using Visual C++ 6.0 and the JDK-1.4.1.The visual C++ project i opened is a console application thqt isn't using MFC.
I've been inspired by the tutorial on Native method to write the following C++ code:
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
JavaVMInitArgs vm_args;
JavaVMOption options[4];
options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
options[1].optionString = "-Djava.class.path=."; /* user classes */
options[2].optionString = "-Djava.library.path=."; /* set native library path */
options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 4;
vm_args.ignoreUnrecognized = true;
fprintf(stdout, "works ?\n");
/* Note that in the Java 2 SDK, there is no longer any need to call
* JNI_GetDefaultJavaVMInitArgs.
*/
//causes the bug
res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
It compiles Ok which is good... and i think my code is correct...
but the real problem is Executing the code.When my code compiled ok(with jvm.lib), i tried to run it, but whatever the Executable, Source,Include, Library path i set, it didn't find the jvm.dll file.windows couldn't find the jvm.dll file !!! it kept giving me in a pop up :
JVM DLL is required and not Found.
I tried to set a better PATH... but it didn't help.
That's when i decided to put a Jvm.dll file in the c:\windows directory hoping windows would then find the jvm.dll file...
It did but then i had an error:
TESTCONSOLE a caus� une d�faillance de page dans
le module JVM.DLL � 017f:6d3e24c9.
Registry :
EAX=00000000 CS=017f EIP=6d3e24c9 EFLGS=00010202
EBX=00760850 SS=0187 ESP=0063fb68 EBP=0063fca0
ECX=00000000 DS=0187 ESI=780264a9 FS=456f
EDX=81a3b848 ES=0187 EDI=0063fdf8 GS=0000
bytes at CS : EIP :
80 20 00 8d 7c 24 14 83 c9 ff 33 c0 f2 ae f7 d1
heap :
0063fdf8 0063fdd0 0063fca0 00000000 0000c0d0 57003a43 4f444e49 4a005357 442e4d56 00004c4c 00000000 00000000 00000000 00000000 00000000 00000000
I don't understand.I am lost...
I will be extremely grateful of any help, in fact I am offering 10 dollars to the best helper.