Windows – How to repair a broken .jar association in Windows 10

file associationjavawindows 10

While trying to run a .jar file (Optifine installer for Minecraft), I accidentally thought that I could use the OpenJDK package that comes with Android Studio to run it. However, I was wrong, and now I can only run .jar files form the command line (Using java -jar from the Oracle Java installation).

I've installed the JDK (Along with the runtime) and tried to set the association for jar files to the Oracle Java installation using Windows Explorer, but it keeps on referencing the (not working) OpenJDK installation.

How can I set the extention for .jar files be set to the Oracle Java installation?

Note: I have Java installed to C:\Program Files\Java\jre-9.0.1

Best Answer

It should be possible from the system settings (link) and via the assoc (link) and ftype command line commands (link).

E.g. my present settings are:

C:\Users\marc>assoc .jar
.jar=jarfile

C:\Users\marc>ftype jarfile
jarfile="C:\Program Files\Java\jre1.8.0_151\bin\javaw.exe" -jar "%1" %*

It is possible to change those settings via these tools.