开发者

Why is my jar producing a NoClassDefFoundError when the class is listed in MANIFEST.MF?

开发者 https://www.devze.com 2023-02-03 20:03 出处:网络
I have created jar in the following folder usr/local/bin/niidle.jar and my MANIFEST.MF file is as follows:

I have created jar in the following folder usr/local/bin/niidle.jar and my MANIFEST.MF file is as follows:

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

I verified that the file hector-0.6.0-17.jar is also present in the folder:

/Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar

I don't want to give full class-path name in MANIFEST.MF file, because I have to run this jar on another machine. So I gave only jar file name Class-Path=hector-0.6.0-17.jar in MANIFEST.MF file.开发者_C百科

In spite of mentioning the Class-Path in MANIFEST.MF file, when I run this using command:

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

It is showing the 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

Please give me a solution for this error message.


Class-Path is relative or absolute to the directory where your jar file is located. so for your case you have to hector-0.6.0-17.jar to /usr/local/bin

0

精彩评论

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

关注公众号