Running JAR file on Windows

DonX picture DonX · Dec 27, 2008 · Viewed 1.2M times · Source

I have a JAR file named helloworld.jar. In order to run it, I'm executing the following command in a command-line window:

java -jar helloworld.jar

This works fine, but how do I execute it with double-click instead? Do I need to install any software?

Answer

Brian Kelly picture Brian Kelly · Dec 27, 2008

Easiest route is probably upgrading or re-installing the Java Runtime Environment (JRE).

Or this:

  • Open the Windows Explorer, from the Tools select 'Folder Options...'
  • Click the File Types tab, scroll down and select JAR File type.
  • Press the Advanced button.
  • In the Edit File Type dialog box, select open in Actions box and click Edit...
  • Press the Browse button and navigate to the location the Java interpreter javaw.exe.
  • In the Application used to perform action field, needs to display something similar to C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" % (Note: the part starting with 'javaw' must be exactly like that; the other part of the path name can vary depending on which version of Java you're using) then press the OK buttons until all the dialogs are closed.

Which was stolen from here: http://windowstipoftheday.blogspot.com/2005/10/setting-jar-file-association.html