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?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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.
javapenguin (May 31st, 2012)
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.
javapenguin (May 31st, 2012)
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?