Java 在 Windows 10 上运行 JAR 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39972506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running JAR file on Windows 10
提问by Asnira
I have made a Jar file, but I cant make it to run by double clicking.
It works fine using java -jar name.jaror by making a batch file.
I have already reinstalled jdk1.8.0_102, set the JAVA_HOMEvariable and javaw.exein the jre folder is already the default program to run it.
so how do I make it to run by double clicking?
我已经制作了一个 Jar 文件,但我无法通过双击运行它。
使用java -jar name.jar或制作批处理文件可以正常工作。
我已经重新安装了 jdk1.8.0_102,设置了JAVA_HOME变量并且javaw.exe在 jre 文件夹中已经是运行它的默认程序。
那么如何让它通过双击运行呢?
回答by jobr97
- Start "Control Panel"
- Click "Default Programs"
- Click "Associate a file type or protocol with a specific program"
- Double click .jar
- Browse C:\Program Files\Java\
YOUR_JRE_VERSION\bin\javaw.exe - Click the button Open
- Click the button OK
- 启动“控制面板”
- 点击“默认程序”
- 单击“将文件类型或协议与特定程序相关联”
- 双击.jar
- 浏览 C:\Program Files\Java
YOUR_JRE_VERSION\\bin\javaw.exe - 点击按钮打开
- 点击按钮确定
回答by Lawrence Armour
How do I run an executable JAR file? If you have a jar file called Example.jar, follow these rules:
如何运行可执行 JAR 文件?如果您有一个名为 Example.jar 的 jar 文件,请遵循以下规则:
Open a notepad.exe.
Write : java -jar Example.jar.
Save it with the extension .bat.
Copy it to the directory which has the .jar file.
Double click it to run your .jar file.

