jar 中的 MANIFEST.MF 有问题
我已经为我的项目创建了 jar,但 MANIFEST.MF 遇到问题。 我的 MANIFEST.MF 的结构如下:
------------------------
Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: /Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar
----------------------------
当我使用命令运行它时:
>>java -jar /usr/local/bin/niidle.jar arguments...
然后它工作正常...... 但我不需要完整的类路径名称。
所以当我的 MANIFEST.MF 结构如下时: 我希望它使用以下类路径运行:
---------------------
Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: lib/hector-0.6.0-17.jar
----------------------------
现在当我使用命令运行它时:
>>java -jar /usr/local/bin/niidle.jar arguments...
然后它显示错误:---
---Exception in thread "main" java.lang.NoClassDefFoundError: me/prettyprint/hector/api/Serializer
at com.ensarm.niidle.web.scraper.NiidleScrapeManager.main(NiidleScrapeManager.java:21)
Caused by: java.lang.ClassNotFoundException: me.prettyprint.hector.api.Serializer
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more
请告诉我解决方案......
I have created jar for my project,I am having problem with MANIFEST.MF.
structure of my MANIFEST.MF is as follows:
------------------------
Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: /Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar
----------------------------
when I run this using command:
>>java -jar /usr/local/bin/niidle.jar arguments...
then its working properly.....
but I dont want the full Class-Path name.
So when structure of my MANIFEST.MF is as follows:
and I want this to run using following Class-Path:
---------------------
Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: lib/hector-0.6.0-17.jar
----------------------------
and now when I run this using command:
>>java -jar /usr/local/bin/niidle.jar arguments...
then it is showing error:---
---Exception in thread "main" java.lang.NoClassDefFoundError: me/prettyprint/hector/api/Serializer
at com.ensarm.niidle.web.scraper.NiidleScrapeManager.main(NiidleScrapeManager.java:21)
Caused by: java.lang.ClassNotFoundException: me.prettyprint.hector.api.Serializer
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more
Please tell me solution for that.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,所需的库不在实际的类路径上。 这里说:
因此,根据我的理解,java 现在(仅)在此位置查找 hector 库:
注意,如果使用
-jar
选项执行 java,则类路径条目将从 manefest 中获取仅,-cp
或$CLASSPATH
中的其他条目将被忽略。Obviously, the required library is not on the actual classpath. Here it says:
So at my understandig, java now looks for the hector library (only) at this location:
Note, that if you execute java with the
-jar
option, the classpath entries are taken from the manefest only, additional entries in-cp
or$CLASSPATH
are ignored.