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.
After you have built the
Main-Class entry and set up an association of the *.jar extension to
C:\Program Files\java\jre1.8.0_131\bin\java.exe, all you need to do to run the jar is:
java.exe -jar converter.jar
Watch out. Java install sets the association back to javaw.exe
, no console! If you get unhandled Exception
s, you will never
find out about the errors, stack dumps or any other error messages!
To run the jar in an Applet, see Applet for some sample HTML (Hypertext Markup Language) or see
on doing it.
The associations for *.jar and *.jnlp are fragile. They mysteriously change to obsolete versions, or javaw.exe version without a console or even unrelated programs like Winzip.exe. Using the java.exe -jar
myjar.jar syntax in your bat/btm files rather is more robust than myjar.jar. It works even when the associations are
Making Jar Files Double Clickable
In XP, W2003, Vista, W2008, W7-32, W7-64, W8-32, W8-64, W2012, W10-32 and W10-64 you can use the method shown below:.
- Download Johann Löfflmann’s Jarfix.exe.
if you want to hook up your 32-bit JRE or
if you want to hook up your 64-bit JRE. It says on does not
work on W10-32 and W10-64, but it does.
- This will invoke
C:\Program Files\java\jre1.8.0_131\bin\javaw.exe when you run someapp.jar
or double click the someapp.jar file.
- This is Oracle’s official way of doing things — throw away all the console output. I find this
idiotic. You want the output. You want the error messages. You want to invoke
C:\Program Files\java\jre1.8.0_131\bin\java.exe instead.
- To fix the problem, invoke regedit.exe at a run-as-administrator prompt.
"C:\Program Files\Java\jre1.8.0_131\bin\javaw.exe" -jar "%1" %*
and change it to:
"C:\Program Files\Java\jre1.8.0_131\bin\java.exe" -jar "%1" %*
- Alternatively, you might configure a custom jarfix.ini file that uses
java.exe in place of javaw.exe with the /c option.
- You also need a config file if your JRE is not on C: or if you have multiple JREs.
website gives instructions on composing an ini file.
You can also use REGEDIT to patch the generated registry entry manually under run-as-administrator.
There are lots of other methods people have recommended, but this is the only one I found that works.