12

When I download a .jar file to say install a mod to minecraft and double click it, it doesn't run. The loading wheel goes for like two seconds and then stops, and nothing else happens. The .jar I know is set up right because it runs through cmd with the command

    cd "wherever the file is"
    java -jar "file name".jar

So I've already tried to run it with the default program set as javaw.exe in the java\jdk1.7.0_25\jre\bin. Same where nothing happens. So the file association is set to the right place. I am at a loss here.

It isn't so bad since I can still run them through cmd, but when I get to the part in the book about jars, I want to be able to run it through the Windows Explorer GUI, which is like half the benefit of using .jar files that I can see.

Is it possibly a registry error? I have seen a lot of questions specifically about this problem, but most of them it seems were problems with setting up the .jar, which I didn't do, and I don't think that is the case here.

I have Windows Vista 64bit.

If I wasn't specific enough, feel free to ask.

Lightfire228
  • 546
  • 1
  • 5
  • 17
  • Are you sure it's not doing anything? What are you expecting to happen? If you're just looking for console output then you won't see that when running with `javaw`. – DaoWen Aug 25 '13 at 22:19
  • The forge mod loader installer for minecraft is supposed to pop up with a window saying "where do you want to install FML" but it doesn't. whatever is happening isn't sent back to my monitor. it just acts like i never clicked my mouse. – Lightfire228 Aug 26 '13 at 00:08
  • Have you tried running `javaw` from the command line the same way you run `java`? Maybe it'll spit out a helpful error message about why it's not working. – DaoWen Aug 26 '13 at 00:13
  • I ran [javaw -jar the_jar_name.jar] and it did the same thing as [java -jar the_jar_name.jar] did – Lightfire228 Aug 26 '13 at 00:16
  • Running [javaw the_jar_name.jar] did the same thing double clicking it did, absolutely nothing. It just returned the directory line waiting for my next input. nothing else – Lightfire228 Aug 26 '13 at 00:22
  • It's not supposed to work without the `-jar` option if you pass it a JAR file. Look at the documentation: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html – DaoWen Aug 26 '13 at 01:08
  • I'm getting the same problem. I've followed all the advice on other pages etc. Double clicking a jar file causes a quick loading icon (in the Task Manager the process window shows javaw.exe being run for a split second and then closing). If I run the file in cmd it works fine, without any exceptions or errors. I've uninstalled and re-installed java, verified it, tried 32 and 64 bit versions but still not luck. – Rudi Kershaw Nov 13 '13 at 14:50

7 Answers7

17

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)".

Xiddoc
  • 3,369
  • 3
  • 11
  • 37
Meghan
  • 330
  • 3
  • 12
  • 2
    This solution also works for "Windows 10 - x64." Thanks. – Игор May 27 '16 at 07:52
  • It's been 4 years and I have to say, I never actually tried your solution. I wasn't feeling savvy enough to edit the registry (it was our only family computer, and I was young-ish). I also got my own laptop about a year later, so I never had to worry about it anymore. – Lightfire228 Nov 29 '17 at 23:59
  • Great answer, worked perfectly. – Xiddoc Sep 23 '21 at 18:13
6

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

Peter Rowntree
  • 601
  • 5
  • 7
  • 1
    jarfix didn't do it, the problem still persists thanks though – Lightfire228 Aug 26 '13 at 00:01
  • @Lightfire228: Did you make sure that the .jar's META-INF\MANIFEST.MF file contains a line like the following? `Main-Class: some.pkg.SomeClass` – Peter Rowntree Aug 26 '13 at 01:45
  • Yeah it does, but the problem seems to be in the GUI or something similar because i can still run these in CMD. Also i have't made any of these, they are all .jars that have been professionaly made. – Lightfire228 Aug 27 '13 at 18:44
3

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

1

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.

TSR
  • 11
  • 1
0

You have to do RightClick on the jar file and select open with... then, Choose default program... (i think that's the correct translation for "Elegir programa predeterminado" in spanish). On the Open with dialog select Java(TM) Platform SE binary. If you don't see that option you should search for the javaw.exe in your java installation folder, and select it. Also you should check Use the selected program to open this kind of file

Best regards.

JGutierrezC
  • 4,398
  • 5
  • 25
  • 42
  • I have done all that before I asked the question, even when i do that, it still doesn't run it. its almost as if a cmd window pops up reports an error then closes, but it does it too fast for my monitor to display it. That propably doesn't happen but what the computer does isn't relayed back to my monitor thats for sure. – Lightfire228 Aug 26 '13 at 00:05
-2

According to Johann Loefflmann, the root cause for the problem above is, that a program has stolen the .jar association. And he is right! Just follow the link below and install a small file JARFIX and the association will be set back and you can double click any jar file and run it in windows. It works for me (I have the same problem and before these I tried all solutions mentioned in the forum and failed).

https://johann.loefflmann.net/en/software/jarfix/index.html

-3

Right click the jar and open with winzip or winrar

Crickcoder
  • 2,135
  • 4
  • 22
  • 36