java Jar 文件不起作用(它没有启动应用程序)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2482737/
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
Jar File doesn't work (It did not launch the application)
提问by Mr CooL
Previously, I have no problem in running the JAR file generated by NetBeans.
之前运行NetBeans生成的JAR文件没有问题。
However, I encountered the problem now all of a sudden. When I click on the jar, it did not launch the application as if nothing is clocked.
但是,我现在突然遇到了这个问题。当我点击 jar 时,它没有启动应用程序,好像没有任何时钟。
But, it can be run from the project. And also, the size of the Jframe for desktop Java application cannot be set from the NetBeans code also. When it runs, the size of the window different from in the designer.
但是,它可以从项目中运行。而且,桌面 Java 应用程序的 Jframe 的大小也不能从 NetBeans 代码中设置。当它运行时,窗口的大小与设计器中的不同。
Any help please.
请任何帮助。
回答by Brian Agnew
Check your META-INF/MANIFEST.MFfile. It should contain a Main-Class:attribute pointing to the class to run initially.
检查您的META-INF/MANIFEST.MF文件。它应该包含一个Main-Class:指向最初运行的类的属性。
Failing that, what happens if you run it from the console e.g.
如果失败,如果您从控制台运行它会发生什么,例如
java -jar yourjarname.jar
That should give you a much better indication of what's going on.
这应该可以让您更好地了解正在发生的事情。
回答by Thorbj?rn Ravn Andersen
Associate jar files with java instead of javaw. Relaunch. See the error message.
将 jar 文件与 java 而不是 javaw 相关联。重新启动。请参阅错误消息。
回答by Omar Al Kababji
try to check your JAVA_HOME environment variable, and try to right click on the jar and do open with and check what application is used to open it.
尝试检查您的 JAVA_HOME 环境变量,并尝试右键单击 jar 并打开并检查用于打开它的应用程序。

