title: How to get Default JVM INITIAL ARGS In JNI
body: <p>I'm trying to get the default jvm args of the available JVM but I'm getty a strange output. Anyone can point me to what's wrong?</p>
  
  <p>Output:</p>
  
  <pre><code>65542
  �p����Y����k�.L�R���g���J����sk��,��*�Jk��xk��
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>#include "jni.h"
  #include &lt;iostream&gt;
  #include &lt;dlfcn.h&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  void * JNI_FindCreateJavaVM(char *vmlibpath) {
      void *libVM = dlopen(vmlibpath, RTLD_LAZY);
  
      if (libVM == NULL) {
          return NULL;
      }
      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;
  
      void* (*lib_func)(void *) = 0;
  
      lib_func = (void*(*)(void*)) 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;
  }
  </code></pre>