Running jar files directly with Java 1.2,

For command-line oriented environments, you should be able to do
java -jar progname.jar 
 (or on windows, you might prefer 'javaw -jar progname.jar')
or possibly
jre -cp progname.jar
The java runtime should automatically pick up the name of the main class to run in the .jar file ( specified in the "Manifest" file in the jar archive). Some command-line environments will even let you specify that certain files can be treated as "executables" directly. So you could in theory just type "progname.jar" and it would run. However, I do not have specific information on how to do that for any particular platform.

For good GUI environments, you should have a method of specifying new "actions", or "associations", that let you say how you want to run all files ending in ".jar". Then just put in whichever of the above works for you.

MS-windows specifics

In contrast, for MS-windows 95 or newer, you will have to first download this little .bat file, runjar.bat. You should then be able to associate ".jar" files with this program. Note that as of Sun's JRE version 1.4, this is no longer neccessary -- doubleclicking on a .jar file will automatically start java for the file.

Generally speaking, you can use your right mouse button on a .jar file to choose the program you want to open it with. Click the "other" button, then select where you saved the runjar .bat file. Make sure you have checked the "Always use this program" option, or whatever it says as an option.

Once this is done, you should then be able to just double-click on properly written .jar files, and they will run automatically.

Mac specific

If you have a mac, look at my macintosh java page


If you have any suggestions, comments, or "hey, it works on platform xxx, cool", drop me a line!
phil@bolthole.com

Bolthole.com top