[Solved] Run jmegame.jar from within another running jmegame

Good afternoon jMonkeys,

I’ve been playing around quite a bit with jMonkeyEngine the last couple of weeks. Thanks to documentation and this forum its quite straightforward to get going and I could solve every problem i was facing by myself and some research, at least until yesterday.

Basically my project includes a server and 2 clients, one of which beeing a launcher for the other client that ensures the client is up-to-date. Server runs fine, so does the launcher-client (checks current game-client version, updates it if neccessary and can ‘almost’ start it), as well as the game-client(basically doesnt do much yet though).
I can start server, launcher-client and game-client from within JMonkeyEngine SDK, however i cannot really launche the game-client from within a running launcher-client (basically using runtime.exec()) as it always returns exit value 1 after about 2 seconds. I replaced the game-client.jar with a simple jFrame.jar that doesnt use jMonkeyEngine but only opens a simple JFrame) and i could run that from within launcher-client just fine. So i basically cut down my code to

public static void main(String[] args) throws InterruptedException {
Main main1 = new Main();
main1.start();
Thread.sleep(5000);
Main main2 = new Main();
main2.start();
Thread.sleep(5000);
}

with Main class beeing the class that is created by default when creating a new project, the simple blue cube thing,
and it seems you cannot start 2 Applications within the same process (2nd one wont start while 1st one freezes) and obviously also starting it in a subprocess by calling runtime.exec(args) didnt solve it, as the runtime.exec(args) thing is what i actually do in my launcher-client.
So my question is, is there any way to have a jMonkeyEngine-powered Launcher starting a jMonkeyEngine-powered Game? (jMonkeyEngine-powered probably isnt the best term for it, as i guess its only some context related stuff though i didnt find the System.exit(1) that must appear somewhere).
Finally, sorrey for that bible and for noobing around, i hope i didnt break any rule lol, thanks a lot in advance for every tiny bit of idea pushing me towards the right direction and may you all have a nicey day!

Did you hook up to the child process’s output so that you could see what the errors were?

Didn’t do that before, thanks for the idea.
The error output of that process gave me the following:

Mai 01, 2018 7:24:43 PM java.util.prefs.WindowsPreferences
WARNUNG: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(…) returned error code 5.
Mai 01, 2018 7:24:44 PM com.jme3.system.JmeDesktopSystem initialize
INFORMATION: Running on jMonkeyEngine 3.2-stable

  • Branch: HEAD
  • Git Hash: f85624a
  • Build Date: 2018-03-06
    Exception in thread “main” java.lang.UnsatisfiedLinkError: Failed to extract native library to: C:\Users\Alexander\informatik\workspace\jmonkeyengine\GamesLauncher\bulletjme.dll
    at com.jme3.system.NativeLibraryLoader.loadNativeLibrary(NativeLibraryLoader.java:668)
    at com.jme3.system.JmeDesktopSystem.initialize(JmeDesktopSystem.java:348)
    at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:271)
    at com.jme3.system.JmeSystem.newContext(JmeSystem.java:162)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:461)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125)
    at com.samgames.gameuno.Starter.main(Starter.java:44)

So is it basically trying to tell me there is no way? :smiley:

Not at all. From the exception I can see you’re using the native bullet libraries, which need to be extracted from the jars they’re provided in to the file system so the JVM can load/link them. The second client is trying to extract those libraries to this path: C:\Users\Alexander\informatik\workspace\jmonkeyengine\GamesLauncher\bulletjme.dll but is failing. It may be that the process can’t write to that folder (unlikely) or that the bulletjme.dll file is locked because, say, your first process is using it (not sure if that would happen or not but it’s worth looking into).

Ok i actually have been noobing around i guess.
When i do not only build the game-client to run its .jar from within the launcher-client but also the launcher-client and run it all from the launcher-client.jar it works perfectly well, not sure what caused it but i consider it fixed so thanks a lot :smiley:

Well and there goes the explanation, thanks a lot again, seems like it is exactly what you said.

1 Like

Glad you fixed it. :slight_smile:

(Can you mark the topic as [Solved] so others know that you found a solution?)

Like adding [Solved] to the title or some freaking fancy option that is hidden anywhere?:smiley:

1 Like

Nothing fancy. Just an edit to the title (but you already figured that out). :wink: