我刚用Eclipse编写了一个“runnable .jar”(或者是一个普通的.jar,我自己创建了清单。我尝试了两种文件)来自我的Java应用程序。
当我尝试通过双击打开它时,我收到此消息:“无法找到或加载主类”
从命令提示符我可以使用'java -jar xy.jar'运行它。 工作没有任何问题。
有人能帮助我吗?
答案 0 :(得分:1)
确保您的清单文件包含main-class。像这样。
Main-Class:MyPackage.MyClass
您可能希望让eclipse发布您的清单,以便您可以查看它的功能,然后保存该清单文件并继续使用它。还要检查类路径。您也可以在清单中指定。
Here's a link to how to set the entry point in the manifest
您可能还需要将类路径放在清单中。
Manifest-Version: 1.0
Class-Path: MyUtils.jar
Created-By: 1.7.0_06 (Oracle Corporation)
可在此处找到:Adding classpath to manifest