Run executable jar on double click on Windows

Summary

Executable JAR files on Windows sometimes fail to launch via double-click due to altered file associations, often by third-party applications. To resolve this, developers can manually re-associate the .jar file type with javaw.exe through the Control Panel's "Associate a file type" settings, typically pointing to C:\Program Files\Java\jre[version]\bin\javaw.exe. If this method proves ineffective, a Java reinstallation followed by a system restart is recommended. As a reliable alternative, executing JARs via the command line using java -jar [JAR_TO_RUN] always functions and can be scripted.

Normally after installing Java, there will be an association between .jar and the javaw.exe. This enables the executable jar to be opened on double click. You can check the association by going to Control Panel -> Programs -> Default Programs -> Associate a file type or protocol with a program.

The default program of a file type can be changed in this dialog. However sometimes there are cases where the file association for .jar may be altered after a third party application installed. The executable jar may not be able to be started normally post that and it still doesn't work even after uninstalling the third party application.

Ideally, following steps can be followed to change the default program back to javaw.exe to run .jar file.

  1. Start "Control Panel"
  2. Click "Default Programs"
  3. Click "Associate a file type or protocol with a specific program"
  4. Double click .jar
  5. Browse C:\Program Files\Java\jre[version]\bin\javaw.exe or C:\ProgramData\Oracle\Java\javapath\javaw.exe 
  6. Click the button Open
  7. Click the button OK

If somehow this method doesn't work. You need to reinstall Java and then restart the computer and the problem should be resolved. 

Also, below command should always work and it can be put in a BAT file and then the batch file can be executed to invoke the jar.

java -jar [JAR_TO_RUN]

Hope this can help someone.

JAVA WINDOWS JAR EXECUTABLE JAR

  RELATED

  COMMENTS

3
Anonymous
Nov 1, 2021 at 3:40 am

how to shutdown the jar file if i activated it through double click

Anonymous
Nov 9, 2021 at 5:23 am

On modern Windows 10 the settings pane has been updated, it only allows you to select from either auto-detected nonsense/suggestions or select something from the Windows store...

Thiemooo
Dec 6, 2021 at 11:22 am

Thank you! Helped me solving my problem :)