wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes java command: classpath or not classpath? 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 "java command: classpath or not classpath?" Watch "java command: classpath or not classpath?" New topic
Author

java command: classpath or not classpath?

Roy Miro
Greenhorn

Joined: Aug 29, 2010
Posts: 12
Hello,

In K&B's book, chapter 10 Question 11

And given the contents o fGetJar.java and Foo.java:


Current directory: test
myApp/Foo.class is placed in MyJar .jar

The following commands to compile and run are:
javac -classpath MyJar.jar GetJar.java
java GetJar
( The output is 8)


Now in question 12:



And given the contents of GoDeep.java and Foo.java:


And MyJar.jar contains the following entry:
myApp/Foo.class
If the current directory is x, which commands will successfully execute GoDeep.class and
produce the output 8? (Choose all that apply.)

A wrong answer is :
java GoDeep


My question: why in q11 we did not have to specify a classpath to java command while in q12 we had to?


Thanks for your time.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Hi Roy,

Search can be your best friend

http://www.coderanch.com/t/270081/java-programmer-SCJP/certification/Self-Test-Last-Chapter

http://www.coderanch.com/t/474863/java-programmer-SCJP/certification/Mistake-GuideBook-SCJP-Java-Chapter


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Roy Miro
Greenhorn

Joined: Aug 29, 2010
Posts: 12
Thank you for the links.
I had searched but maybe not deeply enough

Nice day!
 
GeeCON Prague 2014
 
subject: java command: classpath or not classpath?