executable jar files : Java Glossary

go to home page E words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish 2008-05-19 by Roedy Green ©1996-2008 Canadian Mind Products
index page for letter ⇒ punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
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. For JDK 1.4+, after you have built the Main-Class entry, and set up an association of the *.jar extension to C:\Program Files\java\jre1.6.0_07\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! For JDK 1.1, you need a little more, something like this:
To run the jar in an Applet, see Applet for some sample HTML 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/W2K3/Vista, 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 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\jre1.6.0_07\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\jre1.6.0_07\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
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.59] Take the DavidSuzuki.org nature challenge
You are visitor number 11.
You can get a fresh 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