[PJUG Javamail] Java 101 Classpath issue
Bill Jackson
wajiii at gmail.com
Thu Jul 30 14:06:11 EDT 2009
On Thu, Jul 30, 2009 at 9:08 AM, Richard Johnson <richardj at lingosys.com>wrote:
> Merlyn Albery-Speyer wrote:
> > FYI You can't use both the classpath and the jar switch.
>
> Then why did it (eventually) work, but only with the right classpath and
> jar switches specified?
>
Merlyn is correct; when you use the -jar argument, the -cp value is
ignored. The way to add to the class path in that case is to add it to the
jar's manifest, but the class path wasn't the issue in your case and you
don't need to add anything to it.
The original problem was simply not specifying a valid file name. Adding "-cp
c:\HR_Tools\*.jar" introduced a new problem that masked resolution of the
original problem until the new problem was also resolved.
I see from your command-line output that the shell's wildcard expansion
(replacing the wildcard argument with a space-separated list of file paths)
was causing the second jar matching c:\HR_Tools\*.jar to be interpreted as a
new argument; specifically, the name of the main class you're trying to
run. Without knowing exactly what jars are in your directory, I have to
abstract a little, but basically the command line looked like this
post-wildcard-expansion:
java -cp c:\HR_Tools\some.first.jar c:\HR_Tools\WageEncoder.jar
c:\HR_Tools\some.third.jar
c:\HR_Tools\some.fourth.jar [etc...] -jar C:\HR_Tools\ProjCostByUser
At that point, the -jar argument was being ignored because you had already
specified the main class as "c:\HR_Tools\WageEncoder.jar". This is why the
error message changed to reflect that it couldn't find a class by that
name. Thus, when you first corrected the value of the -jar argument, it
didn't matter.
Once you changed the -cp argument to "c:\HR_Tools\*.jar;C:\HR_Tools\lib\*",
there were no matches for wildcard expansion (the shell was looking for
files matching that whole string), and the command line was then literally:
java -cp c:\HR_Tools\*.jar;C:\HR_Tools\lib\* -jar
C:\HR_Tools\ProjCostByUser.jar
So the -cp argument was safely ignored, the corrected -jar value was no
longer ignored, and the program worked.
Hopefully I wrote this in a way that it makes sense. :)
Cheers,
-Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pjug.org/pipermail/javamail/attachments/20090730/5b713975/attachment.html
More information about the Javamail
mailing list