Re-calling JNI_CreateJavaVM returns -1 after calling DestroyJavaVM


I am trying to recall JNI_CreateJavaVM after calling DestroyJavaVM.

I call them in following order: InitJVM -> ReleaseJVM -> InitJVM

First time when initialing, JNI_CreateJavaVM returns 0 and works fine. second time when initialing after destroying, JNI_CreateJavaVM return -1 and does not work.

What would be the problem?

Here is a function that create JVM:

#elif __linux HRESULT PWNJava::InitJVM(void) { if(m_bRunning) { Log("Error : JVM is already Running! (PWNJava::Init)"); return PWN_FAIL; } const int kNumOptions = 3; JavaVMOption options[kNumOptions] = { { const_cast<char*> ("-Xmx128m"), NULL}, { const_cast<char*> ("-verbose:gc"), NULL}, { const_cast<char*> ("-Djava.class.path=../../Class"), NULL} }; JavaVMInitArgs vm_args; vm_args.version = JNI_VERSION_1_6; vm_args.options = options; vm_args.nOptions = sizeof (options) / sizeof (JavaVMOption); assert(vm_args.nOptions == kNumOptions); int res = JNI_CreateJavaVM(&jvm, reinterpret_cast<void**> (&env), &vm_args); if (res != JNI_OK) { Log("Error : createJavaVM(&jvm, &env, &vm_args)"); return PWN_FAIL; } m_bRunning = true; Log("Success : PWNJava::Init"); return PWN_OK; } #endif

Here is a function deleting JVM:

void PWNJava::ReleaseJVM(void) { if (jvm) jvm->DestroyJavaVM(); jvm = NULL; delete jvm; env = NULL; delete env; m_bRunning = false; Log("Success : PWNJava::ReleaseJVM"); }


Last time I looked at JNI_DestroyJVM(), it said <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html#wp16553" rel="nofollow">"The JDK/JRE still does not support VM unloading, however."</a> Just don't call it, and don't re-initialize it either.


  • Python: I fell in an infinite loop
  • Standard keys functions in curses module
  • Why == is different for Integer and String?
  • Find VMID for running instance
  • What is the correct way to synchronize a shared, static object in Java?
  • How do I shift the decimal place in Python?
  • Odoo 10 - Overriding unlink method
  • Word Open XML Mail Merge
  • Meteor: Do Something On Email Verification Confirmation
  • why do I get the error when installing the gem 'pg'? [duplicate]
  • SignalR .NET Client Invoke throws an exception
  • Using variable in a value field in jMeter
  • Using $this when not in object context
  • Array.prototype.includes - not transformed with babel
  • Volley JsonObjectRequest send headers in GET Request
  • Accessing IRQ description array within a module and displaying action names
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • Build own AppleScript numerical error handling
  • Websockets service method fails during R startup
  • Google cloud sdk not working when python points python3
  • Is there a mandatory requirement to switch app.yaml?
  • Comma separated Values
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • EntityFramework adding new object to nested object collection
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Checking variable from a different class in C#
  • Binding checkboxes to object values in AngularJs
  • failed to connect to specific WiFi in android programmatically
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?