Trying to build a basic launcher for a java game. I'm building the proper command to run the application. When the following command executes in the launcher, the launcher closes as expected, but the command doesn't appear to work - either it doesn't work or the game launches and immediately crashes.
When I print this same command to the console and copy/paste it into console and execute manually, it works perfectly.
/** * */ protected void launch(){ currentStatusMsg = "Launching..."; String cmd = "java -jar"; cmd += " -Djava.library.path=\"" +nativesDirectory.getAbsolutePath() + "\""; cmd += " \""+applicationJar.getAbsolutePath() + "\""; System.out.println(cmd); try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(cmd); //closeLauncher(); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line=null; while((line=input.readLine()) != null) { System.out.println(line); } int exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } I tried adding something to read the output, but nothing is printed.
I was originally using the following format instead, but it has the same effect:
Process pr = Runtime.getRuntime().exec(new String[]{ "java", "-Djava.library.path=\"" +nativesDirectory.getAbsolutePath() + "\"", "-jar", applicationJar.getAbsolutePath()}); Update I realized I was closing the launcher before allowing the debug code to run. The system only prints: "Exited with error code 1"
I finally was able to get the subprocess error to print. It states:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
However, it should be available because the command I'm executing includes the library path, and when this exact command is run manually, it works fine.