You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by esharris <es...@mac.com> on 2009/06/10 15:39:43 UTC

Using apache.commons.cli with Java 1.4.2

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. 

-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p23962584.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


Re: Using apache.commons.cli with Java 1.4.2

Posted by Jörg Schaible <jo...@gmx.de>.
esharris wrote at Mittwoch, 10. Juni 2009 15:39:

> 
> 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.)

What version of commons-cli are you using?
 
> 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.
 
What means "extracted the apache.commons.cli source"?

- Jörg


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


Re: Using apache.commons.cli with Java 1.4.2

Posted by esharris <es...@mac.com>.


sebb-2-2 wrote:
> 
> On 15/06/2009, esharris <es...@mac.com> wrote:
>>
>>
>>
>>  esharris wrote:
>>  >
>>  >
>>  >
>>  > beeky wrote:
>>  >>
>>  >> I'm jumping in sort of late on this, but here goes.
>>  >>
>>  >> To locate local config issues do the following.
>>  >>
>>  >> Create a simple script, call it 'view_cpath.bat', to invoke your app
>> and
>>  >> output the classpath before the line that calls your app.
>>  >>
>>  >> ------ begin script (windows batch file example):
>>  >> echo classpath=%classpath%
>>  >> java my.org.myapp %*
>>  >> -----  end script
>>  >>
>>  >> invoke your app with view_cpath.bat ... normal arg list ...
>>  >>
>>  >> With classpath in hand, check the following:
>>  >> 1. is the cli jar file explicitly named in the classpath?  *.jar will
>>  >> not work.
>>  >> 2. is the jar file actually in the place where the classpath says it
>>  >> should be?  Use dir or ls on classpath entries to be sure.
>>  >> 3. check for misspellings of the jar file name in classpath.  The
>>  >> spelling is relative, obviously both classpath entry and actual jar
>> file
>>  >> must be spelled the same.  Commons jar files have lots of '-' and
>> '.',
>>  >> it is easy to get them wrong.  I've done it many, many times!
>>  >>
>>  >> This will find the problem is it is just local configuration.
>>  >>
>>  >> To make sure you are using the correct jar file do the following.
>>  >> use 'jar tvf  commons-cli-1.1.jar' (from the directory that contain
>> the
>>  >> jar file) to view the contents of the jar file.  In the output you
>>  >> should see something like:
>>  >>
>>  >> 423 Wed Jul 04 19:48:06 EDT 2007
>>  >> org/apache/commons/cli/CommandLineParser.class
>>  >>
>>  >> If you don't see this you have a bad/wrong jar file.  Try downloading
>>  >> again.
>>  >>
>>  >> Hope this helps,
>>  >> -=beeky
>>  >>
>>  >>
>>  >>
>>  >> esharris wrote:
>>  >>> This the only message:
>>  >>>
>>  >>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>  >>> org/apache/commons/cli/CommandLineParser.
>>  >>>
>>  >>> I only have 1.4.2 java on my machine.
>>  >>>
>>  >>> Earl
>>  >>>
>>  >>> Emmanuel Bourg-3 wrote:
>>  >>>
>>  >>>> esharris a écrit :
>>  >>>>
>>  >>>>
>>  >>>>> IMHO, NoClassDefFoundError is hard to debug.
>>  >>>>>
>>  >>>> Could you paste the full stack trace? Also, check that the code was
>>  >>>> compiled with -target 1.4
>>  >>>>
>>  >>>> Emmanuel Bourg
>>  >>>>
>>  >>>>
>>  >>>>
>> ---------------------------------------------------------------------
>>  >>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>  >>>> For additional commands, e-mail: user-help@commons.apache.org
>>  >>>>
>>  >>>>
>>  >>>>
>>  >>>>
>>  >>>
>>  >>>
>>  >>
>>  >>
>>  >> ---------------------------------------------------------------------
>>  >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>  >> For additional commands, e-mail: user-help@commons.apache.org
>>  >>
>>  >>
>>  >>
>>  >
>>  > Initially, there was no CLASSPATH. I added the long name of the
>>  > commons-cli-1.2.jar to the class path. The execution of the bat file
>>  > displayed the expected class path. But this didn't solve the problem.
>> I
>>  > also introduced a JAVA_HOME environment variable that has the path to
>> the
>>  > jdk.
>>  >
>>
>>
>> If I put both jars in the same directory, extract everything out of the
>>  jars, and do a "java {path to main class}", it works.
>>
>>  IMHO, my ability to set the class path to a jar is broken. And my
>> ability to
>>  set the class path to something besides the current directory is broken.
> 
> The java command ignores the classpath if you use the -jar option.
> This is by design, and is documented:
> 
> http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html#-jar
> 
> See the last paragraph for the -jar option.
> 
> The problems you are reporting don't seem to be specific to Commons CLI.
> 
>> --
>>  View this message in context:
>> http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24042102.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
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

The problem is not specified to a particular jar.

If I want to execute a class file with dependencies, I can do it using class
directories or jar files that are not immediately in the current directory.
I just use the -commandpath option and include the current directory.
If I want to execute a Jar file with dependencies, I can't do it. I need to
learn more about how to get Eclipse to create a manifest containing the
right class pathes.
-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24054941.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


Re: Using apache.commons.cli with Java 1.4.2

Posted by sebb <se...@gmail.com>.
On 15/06/2009, esharris <es...@mac.com> wrote:
>
>
>
>  esharris wrote:
>  >
>  >
>  >
>  > beeky wrote:
>  >>
>  >> I'm jumping in sort of late on this, but here goes.
>  >>
>  >> To locate local config issues do the following.
>  >>
>  >> Create a simple script, call it 'view_cpath.bat', to invoke your app and
>  >> output the classpath before the line that calls your app.
>  >>
>  >> ------ begin script (windows batch file example):
>  >> echo classpath=%classpath%
>  >> java my.org.myapp %*
>  >> -----  end script
>  >>
>  >> invoke your app with view_cpath.bat ... normal arg list ...
>  >>
>  >> With classpath in hand, check the following:
>  >> 1. is the cli jar file explicitly named in the classpath?  *.jar will
>  >> not work.
>  >> 2. is the jar file actually in the place where the classpath says it
>  >> should be?  Use dir or ls on classpath entries to be sure.
>  >> 3. check for misspellings of the jar file name in classpath.  The
>  >> spelling is relative, obviously both classpath entry and actual jar file
>  >> must be spelled the same.  Commons jar files have lots of '-' and '.',
>  >> it is easy to get them wrong.  I've done it many, many times!
>  >>
>  >> This will find the problem is it is just local configuration.
>  >>
>  >> To make sure you are using the correct jar file do the following.
>  >> use 'jar tvf  commons-cli-1.1.jar' (from the directory that contain the
>  >> jar file) to view the contents of the jar file.  In the output you
>  >> should see something like:
>  >>
>  >> 423 Wed Jul 04 19:48:06 EDT 2007
>  >> org/apache/commons/cli/CommandLineParser.class
>  >>
>  >> If you don't see this you have a bad/wrong jar file.  Try downloading
>  >> again.
>  >>
>  >> Hope this helps,
>  >> -=beeky
>  >>
>  >>
>  >>
>  >> esharris wrote:
>  >>> This the only message:
>  >>>
>  >>> Exception in thread "main" java.lang.NoClassDefFoundError:
>  >>> org/apache/commons/cli/CommandLineParser.
>  >>>
>  >>> I only have 1.4.2 java on my machine.
>  >>>
>  >>> Earl
>  >>>
>  >>> Emmanuel Bourg-3 wrote:
>  >>>
>  >>>> esharris a écrit :
>  >>>>
>  >>>>
>  >>>>> IMHO, NoClassDefFoundError is hard to debug.
>  >>>>>
>  >>>> Could you paste the full stack trace? Also, check that the code was
>  >>>> compiled with -target 1.4
>  >>>>
>  >>>> Emmanuel Bourg
>  >>>>
>  >>>>
>  >>>> ---------------------------------------------------------------------
>  >>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  >>>> For additional commands, e-mail: user-help@commons.apache.org
>  >>>>
>  >>>>
>  >>>>
>  >>>>
>  >>>
>  >>>
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  >> For additional commands, e-mail: user-help@commons.apache.org
>  >>
>  >>
>  >>
>  >
>  > Initially, there was no CLASSPATH. I added the long name of the
>  > commons-cli-1.2.jar to the class path. The execution of the bat file
>  > displayed the expected class path. But this didn't solve the problem. I
>  > also introduced a JAVA_HOME environment variable that has the path to the
>  > jdk.
>  >
>
>
> If I put both jars in the same directory, extract everything out of the
>  jars, and do a "java {path to main class}", it works.
>
>  IMHO, my ability to set the class path to a jar is broken. And my ability to
>  set the class path to something besides the current directory is broken.

The java command ignores the classpath if you use the -jar option.
This is by design, and is documented:

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html#-jar

See the last paragraph for the -jar option.

The problems you are reporting don't seem to be specific to Commons CLI.

> --
>  View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24042102.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
>
>

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


Re: Using apache.commons.cli with Java 1.4.2

Posted by esharris <es...@mac.com>.


esharris wrote:
> 
> 
> 
> beeky wrote:
>> 
>> I'm jumping in sort of late on this, but here goes. 
>> 
>> To locate local config issues do the following.
>> 
>> Create a simple script, call it 'view_cpath.bat', to invoke your app and 
>> output the classpath before the line that calls your app.
>> 
>> ------ begin script (windows batch file example):
>> echo classpath=%classpath%
>> java my.org.myapp %*
>> -----  end script
>> 
>> invoke your app with view_cpath.bat ... normal arg list ...
>> 
>> With classpath in hand, check the following:
>> 1. is the cli jar file explicitly named in the classpath?  *.jar will 
>> not work.
>> 2. is the jar file actually in the place where the classpath says it 
>> should be?  Use dir or ls on classpath entries to be sure.
>> 3. check for misspellings of the jar file name in classpath.  The 
>> spelling is relative, obviously both classpath entry and actual jar file 
>> must be spelled the same.  Commons jar files have lots of '-' and '.', 
>> it is easy to get them wrong.  I've done it many, many times!
>> 
>> This will find the problem is it is just local configuration.
>> 
>> To make sure you are using the correct jar file do the following.
>> use 'jar tvf  commons-cli-1.1.jar' (from the directory that contain the 
>> jar file) to view the contents of the jar file.  In the output you 
>> should see something like:
>> 
>> 423 Wed Jul 04 19:48:06 EDT 2007 
>> org/apache/commons/cli/CommandLineParser.class
>> 
>> If you don't see this you have a bad/wrong jar file.  Try downloading
>> again.
>> 
>> Hope this helps,
>> -=beeky
>> 
>> 
>> 
>> esharris wrote:
>>> This the only message:
>>>
>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>> org/apache/commons/cli/CommandLineParser.
>>>
>>> I only have 1.4.2 java on my machine.
>>>
>>> Earl
>>>
>>> Emmanuel Bourg-3 wrote:
>>>   
>>>> esharris a écrit :
>>>>
>>>>     
>>>>> IMHO, NoClassDefFoundError is hard to debug.
>>>>>       
>>>> Could you paste the full stack trace? Also, check that the code was 
>>>> compiled with -target 1.4
>>>>
>>>> Emmanuel Bourg
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: user-help@commons.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>
>>>   
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>> 
>> 
>> 
> 
> Initially, there was no CLASSPATH. I added the long name of the
> commons-cli-1.2.jar to the class path. The execution of the bat file
> displayed the expected class path. But this didn't solve the problem. I
> also introduced a JAVA_HOME environment variable that has the path to the
> jdk.
> 

If I put both jars in the same directory, extract everything out of the
jars, and do a "java {path to main class}", it works.

IMHO, my ability to set the class path to a jar is broken. And my ability to
set the class path to something besides the current directory is broken.
-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24042102.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


Re: Using apache.commons.cli with Java 1.4.2

Posted by esharris <es...@mac.com>.


beeky wrote:
> 
> I'm jumping in sort of late on this, but here goes. 
> 
> To locate local config issues do the following.
> 
> Create a simple script, call it 'view_cpath.bat', to invoke your app and 
> output the classpath before the line that calls your app.
> 
> ------ begin script (windows batch file example):
> echo classpath=%classpath%
> java my.org.myapp %*
> -----  end script
> 
> invoke your app with view_cpath.bat ... normal arg list ...
> 
> With classpath in hand, check the following:
> 1. is the cli jar file explicitly named in the classpath?  *.jar will 
> not work.
> 2. is the jar file actually in the place where the classpath says it 
> should be?  Use dir or ls on classpath entries to be sure.
> 3. check for misspellings of the jar file name in classpath.  The 
> spelling is relative, obviously both classpath entry and actual jar file 
> must be spelled the same.  Commons jar files have lots of '-' and '.', 
> it is easy to get them wrong.  I've done it many, many times!
> 
> This will find the problem is it is just local configuration.
> 
> To make sure you are using the correct jar file do the following.
> use 'jar tvf  commons-cli-1.1.jar' (from the directory that contain the 
> jar file) to view the contents of the jar file.  In the output you 
> should see something like:
> 
> 423 Wed Jul 04 19:48:06 EDT 2007 
> org/apache/commons/cli/CommandLineParser.class
> 
> If you don't see this you have a bad/wrong jar file.  Try downloading
> again.
> 
> Hope this helps,
> -=beeky
> 
> 
> 
> esharris wrote:
>> This the only message:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/commons/cli/CommandLineParser.
>>
>> I only have 1.4.2 java on my machine.
>>
>> Earl
>>
>> Emmanuel Bourg-3 wrote:
>>   
>>> esharris a écrit :
>>>
>>>     
>>>> IMHO, NoClassDefFoundError is hard to debug.
>>>>       
>>> Could you paste the full stack trace? Also, check that the code was 
>>> compiled with -target 1.4
>>>
>>> Emmanuel Bourg
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

Initially, there was no CLASSPATH. I added the long name of the
commons-cli-1.2.jar to the class path. The execution of the bat file
displayed the expected class path. But this didn't solve the problem. I also
introduced a JAVA_HOME environment variable that has the path to the jdk.
-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24041320.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


Re: Using apache.commons.cli with Java 1.4.2

Posted by "Wm.A.Stafford" <st...@marine.rutgers.edu>.
I'm jumping in sort of late on this, but here goes. 

To locate local config issues do the following.

Create a simple script, call it 'view_cpath.bat', to invoke your app and 
output the classpath before the line that calls your app.

------ begin script (windows batch file example):
echo classpath=%classpath%
java my.org.myapp %*
-----  end script

invoke your app with view_cpath.bat ... normal arg list ...

With classpath in hand, check the following:
1. is the cli jar file explicitly named in the classpath?  *.jar will 
not work.
2. is the jar file actually in the place where the classpath says it 
should be?  Use dir or ls on classpath entries to be sure.
3. check for misspellings of the jar file name in classpath.  The 
spelling is relative, obviously both classpath entry and actual jar file 
must be spelled the same.  Commons jar files have lots of '-' and '.', 
it is easy to get them wrong.  I've done it many, many times!

This will find the problem is it is just local configuration.

To make sure you are using the correct jar file do the following.
use 'jar tvf  commons-cli-1.1.jar' (from the directory that contain the 
jar file) to view the contents of the jar file.  In the output you 
should see something like:

423 Wed Jul 04 19:48:06 EDT 2007 
org/apache/commons/cli/CommandLineParser.class

If you don't see this you have a bad/wrong jar file.  Try downloading again.

Hope this helps,
-=beeky



esharris wrote:
> This the only message:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/cli/CommandLineParser.
>
> I only have 1.4.2 java on my machine.
>
> Earl
>
> Emmanuel Bourg-3 wrote:
>   
>> esharris a écrit :
>>
>>     
>>> IMHO, NoClassDefFoundError is hard to debug.
>>>       
>> Could you paste the full stack trace? Also, check that the code was 
>> compiled with -target 1.4
>>
>> Emmanuel Bourg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>>
>>     
>
>   


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


Re: Using apache.commons.cli with Java 1.4.2

Posted by esharris <es...@mac.com>.
This the only message:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/cli/CommandLineParser.

I only have 1.4.2 java on my machine.

Earl

Emmanuel Bourg-3 wrote:
> 
> esharris a écrit :
> 
>> IMHO, NoClassDefFoundError is hard to debug.
> 
> Could you paste the full stack trace? Also, check that the code was 
> compiled with -target 1.4
> 
> Emmanuel Bourg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-apache.commons.cli-with-Java-1.4.2-tp23962584p24035021.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


Re: Using apache.commons.cli with Java 1.4.2

Posted by Emmanuel Bourg <eb...@apache.org>.
esharris a écrit :

> IMHO, NoClassDefFoundError is hard to debug.

Could you paste the full stack trace? Also, check that the code was 
compiled with -target 1.4

Emmanuel Bourg


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


Re: Using apache.commons.cli with Java 1.4.2

Posted by esharris <es...@mac.com>.


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


Re: Using apache.commons.cli with Java 1.4.2

Posted by Emmanuel Bourg <eb...@apache.org>.
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