I\'ve been struggling for a while now with this problem and i can\'t seem to fix it. i already have tried different approaches (Runtime.exec(), ProcessBuiler) but none seem
Since it is another Java program you might want to consider running it in the same process because it's much easier to communicate between the two programs if they live in the same process. Have you tried running the command outside your program? Does it work? What does the meta-inf.mf file in the jar hold? It might be that the classpath in the meta-inf.mf file isn't relative so any dependent jars can't be found.
The problem is this:
String startupCommand = "java -jar \"" + this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replace("%20", " ") + "\"";
/* more stuff */ builder.command(startupCommand);
This means Jav will look for a command named java -jar ...stuff with spaces...
. But what you want is, that Java looks for a command named java
and give that command several parameters.
You should use
/*...*/ builder.command("java", "-jar", jarLocation) /*...*/