1

I have created jar in folder /usr/local/bin/niidle.jar.

And I have cerated MANIFEST.MF in jar as follows:

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

And my 'hector-0.6.0-17.jar' file is present in following folder:

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

And I have added this 'hector-0.6.0-17.jar' in niidle.jar folder as follows:

niidle.jar/lib/hector-0.6.0-17.jar

And when I run this using command:

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

then I am getting error message as follows:

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

And When I run again using different command as follows:

java -cp /Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar -jar /usr/local/bin/niidle.jar arguments..... 

---------------Then also I am getting the same 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-------------

so tell me what is solution for that.or any modification in MANIFEST.MF in jar

aioobe
  • 413,195
  • 112
  • 811
  • 826
dhananjay
  • 57
  • 1
  • 2
  • 6
  • possible duplicate of [problem with setting the class path in manifest.mf within jar file](http://stackoverflow.com/questions/4667281/problem-with-setting-the-class-path-in-manifest-mf-within-jar-file) – Erick Robertson Jan 13 '11 at 10:50
  • So, Atul, are you having problems with the manifest in your jar? –  Jan 13 '11 at 15:15

3 Answers3

2

java -cp /Projects/EnwelibDatedOct13/Niidle/lib/hector-0.6.0-17.jar -jar /usr/local/bin/niidle.jar arguments.....

You can't use the -cp switch together with the -jar switch.

From http://mindprod.com/jgloss/classpath.html:

If you use the -jar option, java.exe ignores the classpath. It will only look in that jar!! Try using the manifest Class-Path instead to get Java to look in auxiliary jars


And I have added this 'hector-0.6.0-17.jar' in niidle.jar folder as follows:

To my knowledge, you can't nest .jar files this way.

Since you have Class-Path: hector-0.6.0-17.jar you need to have the needle.jar and the hector-0.6.0-17.jar side by side and run niidle.jar from their common directory (using the -jar switch if you like).

aioobe
  • 413,195
  • 112
  • 811
  • 826
0

Line niidle.jar/lib/hector-0.6.0-17.jar is confusing. Is niidle.jar directory or file? I'd suggest you to post your full manifest, directory structure, command line you are using and current working directory.

But generally you should write in your manifest: Class-Path: hector-0.6.0-17.jar

then put all jars in one directory. Let's call it foo. Now open command prompt, go to foo and run

java -jar niidle.jar args...

And I believe that everything will work. Then if you wish play with location of your jars.

AlexR
  • 114,158
  • 16
  • 130
  • 208
0

For setting up "jars within jars" take a look at this question:

Classpath including JAR within a JAR

Community
  • 1
  • 1
dogbane
  • 266,786
  • 75
  • 396
  • 414