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

  • 1
    put Oracle Java first in your PATH. – DavidPostill Jan 13 '18 at 23:00

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

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.

  • Is there a way to force Windows to use these definitions? I don't have any program associated with Java (In windows explorer), and it won't show up as a jarfile, even after a reboot after setting it to what you described – James007 Jan 14 '18 at 3:07
  • This kind of association only tells how to handle the invocation of files with extension .jar, Check the link for ftype above to see how to set it by yourself. – mvw Jan 14 '18 at 4:33
  • What do you get when entering assoc .jar? – mvw Jan 14 '18 at 4:34
  • .jar=jarfile. When I run ftype jarfile, I get the same output you do, except with a newer version of Java (9.0.1) than you. – James007 Jan 14 '18 at 6:19
  • What happens if you try to execute javaw.exe according to your jarfile setting (with the full path prepended)? Does it work? – mvw Jan 14 '18 at 21:54

I had the same problem with Windows 10 and it turned out to be due to another program "stealing" the .jar file association.

Johann N. Löfflmann has investigated this problem and has a solution using his program jarfix.exe

see the site: http://johann.loefflmann.net/en/software/jarfix

for his analysis and to download the fix.

  • 2
    Welcome to super user. We expect answers to be self contained as far as possible - so having a little more than "Someone has looked into it, and has an app for it" – Journeyman Geek Sep 12 '19 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.