Hi

Add the JNIGetDefaultJavaVMInitArgs, plus you need to
add your class path to vm_args.classpath



I have a C++ class which does all this for you, email me off list
and I'll send it to you.

Regards

--Jools




>From: Pierre Heroux <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Problem with JNI_CreateJavaVM()
>Date: Mon, 20 Sep 1999 17:54:51 +0200
>
>I have a "Segmentation fault (core dumped)" message when I execute the
>following source.
>
>#include <jni.h>
>#include <iostream>
>
>int main()
>   {
>   const int nOpts = 4;
>   JavaVMOption options[nOpts];
>   int ii=0;
>   options[ii++].optionString = "-Djava.compiler=NONE";
>   options[ii++].optionString = "-Djava.class.path=.";
>   options[ii++].optionString = "-Djava.library.path=.";
>   options[ii++].optionString = "-verbose:jni,class,gc";
>
>   JavaVMInitArgs vm_args;
>   vm_args.version = JNI_VERSION_1_2;
>   vm_args.options = options;
>   vm_args.nOptions = nOpts;
>   vm_args.ignoreUnrecognized = JNI_TRUE;
>
>   JavaVM *jvm;
>   JNIEnv *env;


JNI_GetDefaultJavaVMInitArgs( &vm_args );




>   jint res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args); /*debugger
>message : Program received signal SIGSEGV, Segmentation fault.
>0x401d5ca8 in main_arena ()*/
>   if(res < 0)
>     {
>     cerr << "Can't create Java VM" << endl;
>     exit(1);
>     }
>   cout << "JNI_CreateJavaVM() is OK" << endl;
>   jvm->DestroyJavaVM();
>   }
>
>g++ -g simple.cpp -L/usr/local/jdk/jre/lib/i386
>-L/usr/local/jdk/jre/lib/i386/classic
>-L/usr/local/jdk/jre/lib/i386/native_threads -ljava -ljvm -lpthread
>-lhpi -o Simple
>Simple
>
>I use java version "1.2"
>Classic VM (build Linux_JDK_1.2_pre-release-v2, native threads, nojit)
>on RedHat5.2
>
>
>Thanks a lot,
>Pierre
>
>
>
>
>----------------------------------------------------------------------
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact 
>[EMAIL PROTECTED]
>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to