I have a java-based application launcher that uses ProcessBuilder (have tried Runtime.getRuntime().exec(new String[]{} as well) that launches another java application via a command.
When I run the command manually, it works properly. The game launches, no errors.
java -jar -Djava.library.path="./lib/natives" mygame.jar
When the same command (with absolute paths) is run from the launcher:
ProcessBuilder pb = new ProcessBuilder(
"java",
"-jar",
"-Djava.library.path=\"" +nativesDirectory.getAbsolutePath() + "\"",
applicationJar.getAbsolutePath());
pb.redirectErrorStream(true);
pb.directory(applicationDirectory);
I see the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
I've tried multiple variations but it just seems like the command will never properly set the library path when being run from the java launcher.
Is there anything else I can try? Why would the command work for me, but not the launcher? I've tried the ProcessBuilder because I was worried it might be problems with spaces in the file paths (despite having quotes around it)
Is there a better way to let my application dictate/discover where the libs/native files are, avoiding having to always pass the argument anyway?