W3C home > Mailing lists > Public > public-qa-dev@w3.org > July 2007

Re: NoClassDefFoundError is driving me insane!

From: Ville Skyttä <ville.skytta@iki.fi>
Date: Sat, 7 Jul 2007 23:12:52 +0300
To: "Sheppard, Eric" <es1482@att.com>
Cc: public-qa-dev@w3.org
Message-Id: <200707072312.52925.ville.skytta@iki.fi>

On Friday 06 July 2007, Sheppard, Eric wrote:
> I would very much like to get the CSS Validator working on my local
> machine command line but Java is ignoring all class paths! Java is JDK
> 1.5.0_10 on a Unix host.
>
> # cd {dir containing jars}
> # export
> CLASSPATH=css-validator.jar:jigsaw.jar:servlet-api.jar:tagsoup-1.1.3.jar
>
> :xercesImpl.jar:xml-apis.jar
>
> # java -jar css-validator.jar
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/w3c/tools/resources/ProtocolException

From "man java":

    -jar
        Execute a program encapsulated in a JAR file. [...]
        When you use this option, the JAR file is the source of all user
        classes, and other user class path settings are ignored.

In other words, an app that is supposed to be run like "java -jar ..." needs 
to be self-contained in the jar or the classpath set in the Class-Path 
attribute of the jar's META-INF/MANIFEST.MF, and obviously things specified 
in the manifest Class-Path found where expected.  Running the main class the 
usual way by its name (without "-jar") does not have this limitation.
Received on Saturday, 7 July 2007 20:13:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 19 August 2010 18:12:48 GMT