Invoking JVM case- Not able to find the Class
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   deepak_singh
Posted On:   Tuesday, February 28, 2006 01:33 AM

Hello I have a problem regarding class not found. My Java Package is in D:commbtversonageneric Native Library is in D:PorticusVersonaSDK Invoking code is in D:PorticusJNIVoiceTest I gets cls value NULL. Its not able to find VoiceLibraryInvoker Class. I made all possible changes in the options but invain. Please Help me out. int main( int argc, char* argv[], char **envp ) { JavaVMOption options[5]; JavaVMInitArgs vm_args; JNIEnv *env = 0; long result; jmethodID mid; jfieldID fid; jobject jobj; jclass cls; int i, asize; jvm = 0; options[0].optionString = "-Djava.compiler=   More>>


Hello
I have a problem regarding class not found.

My Java Package is in D:commbtversonageneric
Native Library is in D:PorticusVersonaSDK
Invoking code is in D:PorticusJNIVoiceTest

I gets cls value NULL. Its not able to find VoiceLibraryInvoker Class. I made
all possible changes in the options but invain. Please Help me out.


			
int main( int argc, char* argv[], char **envp )
{
JavaVMOption options[5];
JavaVMInitArgs vm_args;
JNIEnv *env = 0;
long result;
jmethodID mid;
jfieldID fid;
jobject jobj;
jclass cls;
int i, asize;
jvm = 0;

options[0].optionString = "-Djava.compiler=NONE";
options[1].optionString = "-Djava.class.path=D:"; /*user classes */
options[2].optionString = "-Djava.library.path=D:\Porticus\VersonaSDK"; /* set native library path */
options[3].optionString = "-verbose:jni";
options[4].optionString = "-Xcheck:jni";

vm_args.options = options;
vm_args.nOptions = 5;
vm_args.version = JNI_VERSION_1_4;
vm_args.ignoreUnrecognized = JNI_FALSE;

//result
std::cout < < "Invoking the JVM" < < std::endl;

result = JNI_CreateJavaVM( &jvm, (void **)&env, &vm_args );
if(result == JNI_ERR ) {
std::cout < < "Error invoking the JVM" < < std::endl;
return -1;
}

//com.mbt.versona.generic.
cls = env->FindClass("com.mbt.versona.generic.VoiceLibraryInvoker");
if( cls == NULL ) {
std::cout < < "can't find class VoiceLibraryInvoker" < < std::endl;
getch();
return -1;
}
std::cout < < "Calling Methods" < < std::endl;

env->ExceptionClear();

jobj=env->NewObject( cls, mid);

mid=env->GetMethodID( cls, " ", "()V" );
env->CallObjectMethod( jobj, mid);
mid = env->GetMethodID( cls, "InvokerMethod", "()I" );

env->CallObjectMethod( jobj, mid);
jint res = (jint) env->CallObjectMethod( jobj, mid );
std::cout < < "Result : " < < res < < std::endl;

env->DeleteLocalRef(jobj);

/* We pass the thread number to every thread */
/* for (i = 0; i < 5; i++)
_beginthread(thread_fun, 0, (void *)i);
Sleep(1000); /* wait for threads to start */

jvm->DestroyJavaVM();
getch();
return 0;
}



Regards
Deepak Singh

   <<Less

Re: Invoking JVM case- Not able to find the Class

Posted By:   ankush_purwar  
Posted On:   Tuesday, February 28, 2006 03:40 PM

Are you able to load DLL inside JVM?
About | Sitemap | Contact