first jvm: is for calling java.util.prefs.Preferences to retrieve system settings (classpath,library path of installed java app).
second jvm: calls java app with help of retrieved Preferences (see above).
this does not work. there seems to be problems with creating two virtual machines within a short time, even if i use DestroyJavaVM. both JNI virtual machines are using different variables so there cannot be a variable clash.
if it is not possible to create two jvms within a short time, maybe i should create a jvm only once and call Runtime.exec() with JNI to call my java app?
Why would you want to create a JVM to read settings which you would then use to start another JVM? The settings used to start the first would presumably be defaults, so you're not going to learn anything you didn't already know by doing this, are you?
my first jvm is retrieving settings with java.util.prefs.Preferences API. these settings have been set beforehand with a java installer programm, which installed my java GUI application. these settings aren't default values they depend on directories the user choses in a installer wizard.
and i need these settings (java.class.path,library.class.path) to make it possible to start my main java GUI application from a C++ application.
Unfortunately you cannot create multiple vms in the same process in JNI, even by doing it sequentially (create exec destroy create exec destroy ...). It's simply not possible. To achieve what you want you'll have to do it with two sequential processes.
will have to use Runtime.exec() to fork a new process then.
Sounds like it but you can call Runtime.exec from JNI so at least you don't have to leave C++. Still, it sounds to me like you don't need to do that, i.e. start another process. Unless your settings are -X settings, I'm pretty sure you can change the settings at runtime. What settings are you looking to change?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop