JNI_CreateJavaVM in a C program results in Segmentation fault in Linux
843829May 5 2003 — edited Jul 13 2005Hi there,
I was testing a C program in Linux that uses JNI_CreateJavaVM method. I am using J2SDK 1.4.1_02 and RedHat Linux 8.0.
The program compiles fine with gcc, but when I run it, I get the "Segmentation fault" message.
This is an excerpt from my C program (similar to many other examples):
void Request_response(Message px, Message py)
{
jint res;
JavaVM *jvm;
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[3];
jclass cls;
jmethodID mid;
jclass stringClass;
options[0].optionString = "-Djava.compiler=NONE";
options[1].optionString = "-Djava.class.path=.";
options[2].optionString = "-verbose:jni";
vm_args.version = JNI_VERSION_1_4;
vm_args.nOptions = 3;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_TRUE;
res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
...
...
I also used the debuger and it said:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8192 (LWP 19644)]
0x402be7aa in os::get_system_properties () from /usr/lib/libjvm.so
I am not very skilled with the debugger - what can I check concerning the message?
Please, help! I would be very grateful for any suggestion since right now I am really without a clue...
Thanks in advance,
Marko