executable jar files : Java Glossary

executable jar files

Executing Jar Files

One of the most useful associations to set up is to make *.jar files executable with java.exe (see below for details how). Then you can just type the name of the jar on the command line to start it executing. ForJava version 1.4 or later, after you have built the Main-Class entry, and set up an association of the *.jar extension to C:\Program Files\java\jre7\bin\java.exe, all you need to do to run the jar is:

converter.jar
or
java.exe -jar converter.jar
Watch out. Java install sometimes sets the association back to javaw.exe, no console! If you get unhandled Exceptions, you will never find out about the errors, stack dumps or any other error messages!

ForJava version 1.1, you need a little more, something like this:

To run the jar in an Applet, see Applet for some sample HTML (Hypertext Markup Language) or see

on doing it.

Making Jar Files Double Clickable

In W98/Me/NT/W2K, you can set up the extension *.jar so that when you double click on a jar file in the disk explorer it will start executing the main-class of the jar. In XP/W2003/Vista/W7-32/W7-64, you need to buy an associations editor utility such as Creative Element Power Tools.
  1. Click Start ⇒ Disk Explorer ⇒ View ⇒ Options ⇒ File Types ⇒ Executable Jar file ⇒ edit.
  2. If there is no Executable Jar file entry click new to create one and fill in the Description of type to jar - Java executable.
  3. Change the name of the entry from Executable Jar file to something that will sort where you expect it like jar - Java executable.
  4. Change the content type to the proper MIME (Multipurpose Internet Mail) type application/java-archive. See MIME for details.
  5. Set default extension for Content type to *.jar.
  6. Click open ⇒ edit .
  7. If there is no open, Click new and set the action to open.
  8. Set the application to perform to: "C:\Program Files\java\jre7\bin\javaw.exe" -jar "%1". You can browse or adjust as necessary to account for where you put your javaw.exe. javaw.exe will hide the console output. To see the console output, associate java.exe instead. I always associate with java.exe myself. Without the console output, if anything goes wrong, you have no clue what the problem is.
  9. Uncheck DDE.
  10. Click OK.
  11. Click new and set the action to execute.
  12. Set the application to perform to: "C:\Program Files\java\jre7\bin\javaw.exe" -jar "%1". You can browse or adjust as necessary to account for where you put your javaw.exe
  13. Uncheck DDE.
  14. Click OK.
  15. Click new and set the action to edit.
  16. Set the application to perform to: "C:\Program Files\WinZip\winzip32.exe" "%1". You can browse or adjust as necessary to account for where you put your WinZip program.
  17. Uncheck DDE.
  18. Click OK.
  19. Click execute ⇒ set default.
  20. Click always show extension.
  21. click change icon. Choose a nice icon. Perhaps some friendly artist could provide me with an jar.ico file I could share with everyone.
  22. click close, close.
  23. Write a letter to Microsoft asking them to automate this bubblegum. Tell them to end the warring between apps. Allow more than one app to register per function. The ones you use most often should bubble to the top. Tell them that whether apps are properly installed or uninstalled, this information should be self-healing.

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/executablejar.html J:\mindprod\jgloss\executablejar.html
logofeedback Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email If you want your message kept confidential, not considered for posting, please explicitly specify that.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.212]
You are visitor number 11.