I can run .jar files through cmd, but I cannot double click them [closed]
I had the same problem, and it turns out that the .jar file association in the registry was broken. The following steps fixed it:
- Open the Registry Editor, and navigate to
HKEY_CLASSES_ROOT\jarfile\shell\open\command
, and modify the value of the Default key as follows - Replace
[Location of your JRE]
in"[Location of your JRE]\bin\javaw.exe" -jar "%1" %*
with the root directory of your JRE installation. For example,"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
. - Repeat the above steps for
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command
.
I have a Windows 7 machine, but I assume this would work for 32-bit environments as well.
EDIT: Fixed the path in the example - it should use the "Program Files" directory and not "Program Files (x86)".
If you don't care too much about understanding the underlying problem, this might help:
http://johann.loefflmann.net/en/software/jarfix/index.html
--and a double-clickable .jar needs to have Main-Class correctly set in MANIFEST.MF
Just to reiterate - Meghan's answer fixed my problem of not being able to double-click to start a jar in Windows 7.
Open Registry editor
Navigate to HKEY_CLASSES_ROOT->jarfile->shell->open->command
Modify (Default) to
"[Path to working JRE]/bin/javaw.exe" -jar "%1" %*
Make sure .jar files are opened by [Path to working JRE]/bin/javaw.exe by default
I had the same problem too. I tried to reinstall my JRE, and nothing happens. I also changed "C:\Program Files\Java\jre1.8.0_271\bin\javaw.exe" -jar "%1" %*
, but same as before.
In the second experiment, I ran it in CMD using java -jar [myFileName].jar
in my directory where it saved and it worked. And then I realized that it worked using java.exe instead javaw.exe. So, I changed the registry to "C:\Program Files\Java\jre1.8.0_271\bin\java.exe" -jar "%1" %*
and it solved my problem.
I hope it helps your problem too.