PDA

View Full Version : Making a stand-alone executable from a Java program


Captain Carrot
02-22-2008, 04:36 PM
Okay, so say I have a program that reads in two files, does stuff, and prints the result to a third file. This program is in the form of a .java file and a .class file. How can I turn those into a .exe program that will run on someone else's computer without them having to do anything funky with manually running it or anything like that? In other words, the user double-clicks on the executable icon, and the program just runs.

(This is not homework, I'm doing a favor for my mom.)

Jragon
02-22-2008, 04:42 PM
I've personally never bothered because I thought it defeated the purpose of Java, but here's a website outlining various methods of making an executable on double-click jar.

http://www.excelsior-usa.com/articles/java-to-exe.html

Edit: Come to think of it, on occasion i did use the jar manifest option

Capt. Ridley's Shooting Party
02-22-2008, 04:43 PM
I know two methods: you can compile with gcj to create a native executable, or create an executable JAR file (http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html).

ticker
02-22-2008, 04:50 PM
If you create an executable Jar file the target machine will still need to have a Java runtime installed, but otherwise the result is just like clicking on a .exe.

Captain Carrot
02-22-2008, 08:00 PM
Thanks for your help, guys. I ended up going in a different direction*, but this will still probably be helpful when I have a course that requires me to use Java.

*-I found a program that converts Python to .exe, and I found a decent tutorial on a Python extension GUI.