windows 无法运行 JAR 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1724892/
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
Can't Run JAR Files
提问by anon
I can run my project through netbeans but after I make a jar file and double click it I get the error cannot find Java runtime environment? I am on Windows.
我可以通过 netbeans 运行我的项目,但是在我制作一个 jar 文件并双击它之后,我收到错误找不到 Java 运行时环境?我在 Windows 上。
回答by Bozho
Make sure you have JRE installed.
Open the console and type java -version
确保您已安装 JRE。打开控制台并输入java -version
回答by adhanlon
You should download a Java runtime environment.
您应该下载 Java 运行时环境。
回答by Chris K
You don't have a file associate created. Right click on the .jar file in Internet Explorer, select Open With, and navigate to your JRE. Select the java.exe executable, and make sure the command-line argument has ' -jar ' present.
您没有创建文件关联。在 Internet Explorer 中右键单击 .jar 文件,选择打开方式,然后导航到您的 JRE。选择 java.exe 可执行文件,并确保命令行参数包含“-jar”。
The .jar file will be passed as the first argument to the JVM.
.jar 文件将作为第一个参数传递给 JVM。
回答by poundifdef
You might try, as Chris said, making sure the JRE executable is part of your PATH environment variable. Check out "4. Update the PATH variable (Optional)" from this guide.
正如 Chris 所说,您可以尝试确保 JRE 可执行文件是您的 PATH 环境变量的一部分。查看本指南中的“4. 更新 PATH 变量(可选)” 。
回答by poundifdef
It's all about the Manifest - http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html
这都是关于清单的 - http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html
回答by TofuBeer
In Netbeans run the project. It will ask you what class to run (you will see a list of all the classes with a "public static void main(String[])" method). Once you do that the next time you build the class netbeans will show you how to run it (with the -jar witch). Now you should be able to double click on it.
在 Netbeans 中运行该项目。它会询问您要运行哪个类(您将看到所有带有“public static void main(String[])”方法的类的列表)。一旦您在下次构建类时这样做,netbeans 将向您展示如何运行它(使用 -jar 女巫)。现在你应该可以双击它了。
回答by Chris Lacasse
Make sure the JRE bin dir is in your PATH env variable.
确保 JRE bin 目录在您的 PATH 环境变量中。