String command = "java -jar \"/path/to/some/jar/foo.jar\"";
Here is an interesting problem I ran into while doing some work: why is Runtime.getRuntime().exec(command) reporting that it couldn’t access a jar file I was directly trying to invoke in code on Linux but worked no problem on Windows? The generated command was identical on Windows and Linux and copying the command and running it in a terminal executed as it should. WHY DO YOU HATE ME JAVA AND LINUX?
Turns out that it was really only Java hating on me. After playing around with the command, I finally figured out that removing the quotes around the jar path fixed it:
String command = "java -jar /path/to/some/jar/foo.jar";
worked but
String command = "java -jar \"/path/to/some/jar/foo.jar\"";
didn’t.
So what is going on?
(more…)

