[PJUG Javamail] Java 101 Classpath issue

Richard Johnson richardj at lingosys.com
Tue Jul 28 11:54:21 EDT 2009


Looks like you were both right.  First we add *.jar to the classpath:
 
C:\>java -cp c:\HR_Tools\*.jar -jar C:\HR_Tools\ProjCostByUser
Exception in thread "main" java.lang.NoClassDefFoundError:
c:\HR_Tools\WageEncoder/jar
Caused by: java.lang.ClassNotFoundException: c:\HR_Tools\WageEncoder.jar
... blah blah blah
Could not find the main class: c:\HR_Tools\WageEncoder.jar.  Program
will exit.
 
Then we add .jar to the target:
C:\>java -cp c:\HR_Tools\*.jar -jar C:\HR_Tools\ProjCostByUser.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
c:\HR_Tools\WageEncoder/jar
Caused by: java.lang.ClassNotFoundException: c:\HR_Tools\WageEncoder.jar
... blah blah blah
Could not find the main class: c:\HR_Tools\WageEncoder.jar.  Program
will exit.
 
Finally, with an obvious flourish of my own, we add the libs directory
to the classpath too.
C:\>java -cp c:\HR_Tools\*.jar;C:\HR_Tools\lib\* -jar
C:\HR_Tools\ProjCostByUser.jar
You must have one argument - date formatted "yyyy-mm-dd"

Which tells us it ran.
 
Therefore I conclude: 
1. system must be able to find java.exe
2. system must be able to find jar file
3. classpath must include *.jar in cp name
4. classpath must explicitly declare subdirectories
5. java needs .jar in target file name.
 
Boy, I sure screwed that one up before my coffee today.  :-)  Thanks
everyone.
-- 
Richard J.

 

 

________________________________

From: John Watson [mailto:jkwatson at gmail.com] 
Sent: Tuesday, July 28, 2009 8:45 AM
To: Richard Johnson; javamail at pjug.org
Subject: Re: [PJUG Javamail] Java 101 Classpath issue


Also, unless that directory is full of .class files, the classpath won't
do you any good, as java doesn't support jar directories for classpaths
(unless you wildcard it, I think?).


On Tue, Jul 28, 2009 at 11:42 AM, Christian Pich <cmpich at cs.uoregon.edu>
wrote:


	What is the name of your jar file? It appears that you left out
the
	extension .jar in
	   c:\HR_Tools\ProjCostByUser
	I am not sure but the extension is probably required...
	

	Richard Johnson wrote:
	> Hi all,
	>
	> This is no doubt totally obvious, but it eludes me this
morning.  Call
	> it my WTF? for today.  What's going on here, and what's the
fix?
	>
	> ----------- windows xp "cmd" shell:
	>
	> C:\Java\jdk1.6.0_12\jre\bin>java.exe -verbose -classpath
C:\HR_Tools
	> -jar c:\HR_Tools\ProjCostByUser
	> Unable to access jarfile c:\HR_Tools\ProjCostByUser
	>
	> C:\Java\jdk1.6.0_12\jre\bin>
	>
	> -------------
	> Richard J.
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pjug.org/pipermail/javamail/attachments/20090728/e4a8117e/attachment.html 


More information about the Javamail mailing list