开发者

MANIFEST.MF issue

开发者 https://www.devze.com 2023-02-03 23:58 出处:网络
hi I have created a jar inside this folder: \'/usr/local/bin/niidle.jar\' in eclipse. And I have another jar inside/usr/local/bin/niidle.jar.

hi I have created a jar inside this folder: '/usr/local/bin/niidle.jar' in eclipse. And I have another jar inside /usr/local/bin/niidle.jar. In my niidle.jar file,there is one 'lib' folder and in that 'lib' folder,there is another jar file 'hector-0.6.0-17.jar'. I have added this 'hector-0.6.0-17.jar' file in MANIFEST.MF as follows:


Manifest-Version: 1.0
Main-Class: com.ensarm.niidle.web.scraper.NiidleScrapeManager
Class-Path: hector-0.6.0-17.jar

But when I run this using command:

>>java -jar /usr/local/bin/niidle.jar arguments...

It is not working.. It is showing error message:-

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

What is the problem,Please tell me solution for this Exce开发者_如何学Cption...


It really should work! Please double-check, that both jar files (niidle.jar and hector-0.6.0-17.jar are in the same folder. Following the example on the official Java tutorial, it really should work:

/usr/
  local/
      bin/
         niidle.jar
         hector-0.6.0-17.jar

Otherwise, check again, if the hector jar is the very same one that has been used inside eclipse. You may have different versions of the jar for compiling and executing and that could lead to the very same problem. Maybe the missing class is not inside the hector lib.


Addition - if you've written the manifest files with an text editor, make sure, that the last line is an empty line! If the Class-Path Attribute line is the last one and if it does not end with an CR or LF, then it will not be parsed - and the hector jar will not be added to the class path.


http://www.jdotsoft.com/JarClassLoader.php and other jar loaders linked from the page summarize issue and solution

0

精彩评论

暂无评论...
验证码 换一张
取 消