commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esharris <eshar...@mac.com>
Subject Re: Using apache.commons.cli with Java 1.4.2
Date Wed, 10 Jun 2009 20:52:24 GMT



ebourg wrote:
> 
> esharris a écrit :
>> I'm having difficulty using apache.commons.cli with Java 1.4.2. I used
>> Eclipse to develop a simple program that uses apache.commons.cli. The
>> program works within the Eclipse IDE. However, when I export the program
>> as
>> a Jar file and try to run the Jar from the command line (DOS or Unix). I
>> get
>> a NoClassDefFoundErrorerror wrt the CommandLineParser. (In another
>> program
>> that uses apache.commons.cli, running the jar file triggers  the
>> NoClassDefFoundErrorwrt HelpFormatter. So, I think java punts on the
>> first
>> class it sees containing a problem.) 
>> 
>> I also extracted the apache.commons.cli source and built a Jar from it.
>> Strangely, I couldn't compile my program using my cli jar, instead on the
>> standard jar. When I extract classes from my cli jar, I noticed some of
>> the
>> classes in apache.commons.cli are absent. I don't see anything peculiar
>> in
>> the source. 
>> 
> 
> I don't know how your application is packaged, but did you simply try to 
>   put the commons-cli.jar file downloaded from 
> http://commons.apache.org/cli in your classpath ?
> 
> Emmanuel Bourg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 
Yes. I put the jar in my classpath. To accomplish this, I used the
-classpath option in java. Then, as an alternate, I updated the CLASSPATH
environment variable. I did this in both DOS and UNIX. And I had colleagues
try to get the jar to work under 1.4.2. One colleague also spent time
extracting the classes from the jar and putting the classes in the class
path.

According to this site, ...

http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror

... you don't want to confuse ClassNotFoundException with the
NoClassDefFoundError error. NoClassDefFoundError indicates that the class
CommandLineParser was found by the ClassLoader. However, when trying to load
the class, the ClassLoader ran into an error reading the class definition.
So I am assuming the problem is not in the class path. If it was a problem
with the class path, I would get the ClassNotFoundException.

IMHO, NoClassDefFoundError is hard to debug.


-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p23970787.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message