NoClassDefFoundError while trying to run my jar with java.exe -jar…what's wrong?

The -jar option is mutually exclusive of -classpath. See an old description here.

The -jar option is mutually exclusive of -classpath. See an old description here -jar Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file instead of a startup class name.In order for this option to work, the manifest of the JAR file must contain a line of the form Main-Class: classname.

Here, classname identifies the class having the public static void main(String args) method that serves as your application's starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for information about working with Jar files and Jar-file manifests. When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

A quick and dirty hack is to append your classpath to the bootstrap classpath: -Xbootclasspath/a:path Specify a colon-separated path of directires, JAR archives, and ZIP archives to append to the default bootstrap class path. However, as @Dan rightly says, the correct solution is to ensure your JARs Manifest contains the classpath for all JARs it will need.

It would be better to specify a classpath in the JAR's manifest. The bootclasspath is intended for replacing system classes. – Dan Dyer Oct 30 '08 at 13:53 True -- will edit it make it clear this is only a workaround.

– toolkit Oct 30 '08 at 14:01 Aha! That's it! I knew there must be something simple that I was missing.

Just nobody around here has worked with jars enough to notice my error! – Ogre Psalm33 Oct 30 '08 at 14:55 1 Unfortunately, putting the full paths in the manifest seems fraught with peril when deploying from one system to another. The jars will not necessarily live in the same place on both systems.

– Ogre Psalm33 Oct 30 '08 at 14:57 1 You can use relative paths in the manifest. – James Schek Oct 30 '08 at 15:04.

If you use external libraries in your program and you try to pack all together in a jar file it's not that simple, because of classpath issues etc. I'd prefer to use OneJar for this issue.

I looked at OneJar a little bit. That might be a possibility--the license appears to be pretty straight-forward. But I'd still have to get it "approved" where I work in order to use it.

– Ogre Psalm33 Oct 30 '08 at 15:00.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions