This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt: Qn 12 from K&B SCJP 6.0 chapter Development Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt: Qn 12 from K&B SCJP 6.0 chapter Development" Watch "Doubt: Qn 12 from K&B SCJP 6.0 chapter Development" New topic
Author

Doubt: Qn 12 from K&B SCJP 6.0 chapter Development

Gouri Kumari
Greenhorn

Joined: Jul 06, 2010
Posts: 22
Can some one kindly help me with this problem ?
------------
Directory Structure:


Contents of GoDeep.java and Foo.java





MyJar.jar contains
myApp/Foo.class

I compiled GoDeep.java successfully using the javac command from current folder "x": javac -cp test\MyJar.jar GoDeep.java.
However when I try to execute the class file using java -classpath .:test/MyJar.jar GoDeep from current folder"x", a NoClassDefFoundError exception is generated. Why is this happening?





Gouri Kumari
Greenhorn

Joined: Jul 06, 2010
Posts: 22
It was a mistake from my part. I was executing my java programs in Linux but recently I started executing it in Windows 7 and I forgot about changing the separator character for directories from : to ;. The execution of class file works fine after changing the java command to

java -cp .;test\MyJar.jar GoDeep.

Best,
Gouri
 
GeeCON Prague 2014
 
subject: Doubt: Qn 12 from K&B SCJP 6.0 chapter Development