NoClassDefFoundError exception

Hi,

I want to write a native method that returns an array of String. I wrote the following code just for test since I've never worked before with JNI.

JNIEXPORT jobjectArray JNICALL Java_main_RegQuery_getValues (JNIEnv *env, jobject obj){

jclass stringArrCls = env->FindClass("Ljava/lang/String");

if (stringArrCls == NULL){

return NULL;/* exception thrown */

}

jobjectArray result = env->NewObjectArray(10, stringArrCls, NULL);

return result;

}

The code compiles and builds just fine, but when I call the method from java i get the exception:

Exception in thread "main" java.lang.NoClassDefFoundError: Ljava/lang/String

at main.RegQuery.getValues(Native Method)

at main.RegQuery.main(RegQuery.java:6)

I want to add that the C++ code is part of a VC6.0 project and i've set "C:\PROGRAM FILES\JAVA\JDK1.6.0\INCLUDE" and "C:\PROGRAM FILES\JAVA\JDK1.6.0\INCLUDE\WIN32" paths to it.

I suspect that the problem is somepath that is not included in my projects, but I don't know where. Maybe you could help me, please.

Thanks in advance

[1419 byte] By [Ghighia] at [2007-10-3 0:30:42]
# 1
You have a couple errors in your class definition. Try the following:env->FindClass("[Ljava/lang/String;");The bracket indicates you want an array class.The semicolon is required.
bschauwejavaa at 2007-7-14 17:23:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
It works fine now. I just did a lousy beginner's mistake, not reading the documetation right. Anyway, tanks! :)
Ghighia at 2007-7-14 17:23:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...