java can run jar from cmd but not by double clicking

后端 未结 6 594
不知归路
不知归路 2020-12-03 12:26

I just created a jar file using jdk7. I tried running it but kept getting an error. It turned out it was pointing at a jre6 and not the jre in jdk7. So, I used the following

6条回答
  •  暖寄归人
    2020-12-03 13:18

    OK, I found the answer somewhere else but ran into this issue again so came here via google.
    The solution is...

    1. Open up regedit.exe
    2. Either search for "jre6" or follow this:
      HKLM->SOFTWARE->Classes->jarfile->shell->open->command
    3. Change the Data field to the directory of the javaw.exe file that's in your JDK directory.
    4. For the love of God, don't forget to put the weird [-jar "%1" %*] parts on the end of it.
    5. Enjoy outsmarting Oracle.

    Hopefully this'll save some people a bit of time.

    This happened to me when I installed the JRE6 plugin for Chrome, though it could happen when installing any other JRE I guess.

提交回复
热议问题