I tried the Runtime.getRuntime() and the Process exec() method, but it said that the jar wasn't a valid Win 32 Application. So what should I do instead of going the route like I would with an .exe?
Printable View
I tried the Runtime.getRuntime() and the Process exec() method, but it said that the jar wasn't a valid Win 32 Application. So what should I do instead of going the route like I would with an .exe?
The executable you have to run is java (or javaw.exe) passing it the -jar and any other arguments including the name of the jar file.
Say I had a file called file.jar, how would I pass that using the Runtime.getRuntime() and Process exec() method then?
Runtime.exec("java -jar myjarfile.jar")
But unless you don't know anything about the internals aspects of the jar (and making the assumption that the JRE is on the PATH of the client machine - which in many cases it is not), you should be able to add this to your classpath and run it internal to your application.
How would you know if the JRE is on the client machine or not? And if it's not, how do you get it there?