java can run jar from cmd but not by double clicking

后端 未结 6 589
不知归路
不知归路 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:14

    When windows asks you for a program to run it against it won't insert the needed -jar argument in the command line.

    If it's asking you for the exe in which to run it then that means somehow your JRE isn't associated with the .jar extension. You'll need to modify the .jar file registry entry so that it runs c:\path_to_jre\bin\javaw -jar %1 in order for it to work.
    It used to be under File Explorer > Tools > Folder Options > File Types.

    Then look for .jar in there. You should find a text field that shows the executable to run and the command line arguments. That's what you want to modify. You can also do it in the registry editor too, but I've forgotten the HKEY variable path. I'm sure this KBA will help:

    support_microsoft_kb_950505

提交回复
热议问题