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 Tue, 16 Jun 2009 13:59:09 GMT



sebb-2-2 wrote:
> 
> On 15/06/2009, esharris <esharris@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


Mime
View raw message