Class not found exception

I am trying to embedd JVM in my C++ application through JNI. I am using JDK1.4 Beta2. There are couple of issues I am facing..

1. When I call JNI_GetDefaultJavaVMInitArgs with version set to JNI_VERSION_1_2, the call succeeds but the string represnting classpath contains null. And when I change the version to JNI_VERSION_1_1, then it is a valid string? But this creates another problem. When I try to create JVM by calling JNI_CreateJavaVM, the call failes returning error -3 i.e. incorrect version. Is this some kind of known issue with JDK1.4 or am i doing somethng wrong?

2. Then i decided to go ahead to use JNI_VERSION_1_2 when creating JVM. But now when i call FindClass function to get reference to my java class, it fails. Throws exception NoClassDefFoundError.

-- I am running Win2K Adv Server

-- I have not set any CLASSPATH variable

-- I appened "." to the classpath string in JDK1_1InitArgs variable.

Could someone help me fix this issue?

Thanks,

Naveen

[1029 byte] By [naveenkohli] at [2007-9-26 5:46:44]
# 1

I used JDK1.2 (a little bit original :-), but I had the similar problem as you described in most respects.

1. I am not sure if it is known issue or not. Book "The Java Native Interface Programmer's Guide and Specification" authored by JNI architect Sheng Liang says that JNI_GetDefaultJavaVMInitArgs is not required for VERSION_1_2 (I guess it is safe to include the above version) and it has no effect if it is used. When using VERSION_1_2, the syntax of passing env is a little bit different that env has to be cast to be (void**).

2. I got this too. Use ExceptionDescribe to dump more info to see if you can get any clue from it. Mine was due to lack of memory.

Good luck!

Lan

lzhang97 at 2007-7-1 14:09:23 > top of Java-index,Java HotSpot Virtual Machine,Specifications...