java - How to get Default JVM INITIAL ARGS In JNI -
I'm trying to get the JVM's default jvm args available, but I've got weird output. Can anyone tell me wrong?
Output:
65542 p y k .Lr g j sk, * jk xk
code:
< Pre> #include "jni.h" # include & lt; Iostream & gt; # Include & lt; Dlfcn.h & gt; # Include & lt; Cstdlib & gt; using namespace std; Zero * JNI_FindCreateJavaVM (four * vmlibpath) {void * libVM = dlopen (vmlibpath, RTLD_LAZY); If (libVM == faucet) {return tap; } Return dlsym (libVM, "JNI_GetDefaultJavaVMInitArgs"); } Int main () {JavaVMOption vm_options; JavaVMInitArgs vm_args; Vm_args.version = JNI_VERSION_1_6; Vm_args.ignoreUnrecognized = JNI_FALSE; Vm_args.options = & amp; Vm_options; Zero * (* lib_func) (Zero *) = 0; Lib_func = (Zero * (*) (Zero *)) JNI_FindCreateJavaVM ("/usr/lib/jvm/java-6-sun/jre/lib/i386/client/libjvm.so"); Lib_func (& amp; vm_args); Cout & lt; & Lt; Vm_args.version & lt; & Lt; Endl; Cout & lt; & Lt; Vm_args.options [0] .optionString & lt; & Lt; Endl; Return 0; The prototype for JNI_GetCreatedJavaVMs is:
You call the function with a * JavaVMInitArgs
parameter and I'm not sure why you expect your code to be printed properly.
Comments
Post a Comment