wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "java command: classpath or not classpath?" Watch "java command: classpath or not classpath?" New topic

java command: classpath or not classpath?

Roy Miro

Joined: Aug 29, 2010
Posts: 12

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:
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

Joined: Feb 24, 2006
Posts: 6661

Hi Roy,

Search can be your best friend



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

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

Nice day!
I agree. Here's the link: http://aspose.com/file-tools
subject: java command: classpath or not classpath?
Similar Threads
Sun certified programmer book - chapter 10 question 12 - clarification
Doubt at K&b chapter 10,question 11
Doubt about Question 12 in Chapter 10 Quiz (K&B)
Question related to self test question in SCJP (Sierra/Bates) Java 6 book
Questions about classpath on SCJP book.