无法从 abc.jar 加载主类清单属性
嗨,
我使用 eclipse 创建了一个可运行的 .jar 文件,并使用 jdk1.4.2 对其进行了编译,我能够在 Windows 上完美运行它,但每当我在 unix 上运行它时,它会说“无法从 abc 加载主类清单属性。 jar” 为什么会这样
请帮助
Saurabh
HI,
I have created a runnable .jar file using eclipse and compiled it with jdk1.4.2, i am able to run it perfectly on windows but whenever i run it on unix it says "failed to load main-class manifest attribute from abc.jar" Why is it so
Please help
Saurabh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常避免使用可执行 jar。假设,我们有一个类
com.example.MyClass
,它有main
方法,那么“可执行 jar”的清单 (myapp.jar) 需要行然后你可以像这样启动应用程序
除了一些类路径烦恼之外,这与“烦恼”非常相似
:如果使用
-jar
选项运行应用程序,则类路径必须在清单中定义 - 它将忽略任何 CLASSPATH 条目或 -cp 属性。因此,如果您有依赖项,则必须将它们从清单类路径属性复制并粘贴到-cp
属性:I usually avoid executable jars. Assuming, we have a class
com.example.MyClass
that has hasmain
method, then the "executable jar"'s manifest (myapp.jar) needs the lineThen you can start the application like this
Apart from some classpath annoyances, this is pretty similiar to
The "annoyance": if run the application with the
-jar
option, the classpath has to be defined in the manifest - it will ignore anyCLASSPATH
entry or-cp
attribute. So if you have dependencies, you'll have to copy and paste them from the manifests classpath attribute to the-cp
attribute: