Running a .jar file in the command line works fine, but I am unable to execute .jar files on my PC by double-clicking them. What is interesting, the same .jar files successfully execute on my laptop with a double-click.
I included %JAVA_HOME\bin
and JDK_HOME\bin
in the PATH
variable.
I have JAVA_HOME
set to C:\Program Files\Java\jre1.8.0_121
.
I have JDK_HOME
set to C:\Program Files\Java\jdk1.8.0_121
.
For some period of time, the Java(TM) Platform SE binary disappeared from the Open with
list, and I could not add it until I changed the HKEY_CLASSES_ROOT\jar_auto_file\shell\open\command
key in regedit.exe
to the appropriate version:
C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe" "%1".
Here is a snapshot of Windows CMD with java -version
entered on my PC:
I tried the following methods, with no success:
- reinstalling both JRE and JDK,
- associating .jar files with
C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe
, - using
assoc .jar=jarfile
andftype jarfile="C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe" -jar "%1" %*
in command line, - creating a new system Environment Variable OPENDS_JAVA_ARGS and setting it to -jar.
Additional information:
- I am using Windows 7 Professional 64-bit (Service Pack 1) with latest updates installed both on my PC and laptop.
- Running .jar files by double-clicking them used to work on my PC, but suddently stopped working some time ago. I did not modify anything related to Java.
- I have the newest version of both JRE and JDK (Java 8 version 121).
- Of the .jar files I am trying to run, some are GUI Swing applications
and some open the system console (if not already open) using
Runtime.getRuntime().exec(String[])
.
I have already tried fixing this problem with solutions on the following links (without success):
- How to run .jar file by double click on Windows 7 (64)
- How to open/run .jar file (double-click not working)?
- I can run .jar files through cmd, but I cannot double click them
- Can't Run JAR Files
Notes:
- I do not want to open .jar files with WinRAR.
- I do not want to open .jar files by running
java -jar jarfile.jar
in cmd.exe. - I am not looking for a 3rd party application to run .jar files.
For now, I am using C:\Windows\System32\cmd.exe /k "java -jar C:\path\to\jarfile\Program.jar"
as a shortcut location to run jar files, but I am not satisfied with this solution as this opens the console to run even Swing applications.