File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes classpath for jar file K&B 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 "classpath for jar file K&B" Watch "classpath for jar file K&B" New topic

classpath for jar file K&B

Ferwed Kondos

Joined: Sep 27, 2007
Posts: 6
K&B chapter 10 - Q 12

And the following sub-directory structure:


If the current directory is test, and the file pkg/Kit.class is in KitJar.jar, which
command line will produce the output bc ? (Choose all that apply.)
A. java UseKit b c
B. java UseKit a b c
C. java -classpath com UseKit b c
D. java -classpath com:. UseKit b c
E. java -classpath com/KitJar.jar UseKit b c
F. java -classpath com/KitJar.jar UseKit a b c
G. java -classpath com/KitJar.jar:. UseKit b c
H. java -classpath com/KitJar.jar:. UseKit a b c

Answer is H
I dont understand why F is false, why specifying the dot in the classpath is required?
Henry Wong

Joined: Sep 28, 2004
Posts: 20517

Here is the relevant quote from the Sun Java web site:

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ferwed Kondos

Joined: Sep 27, 2007
Posts: 6
Thanks Henry
So the dot in the classpath is to find the class in the current directory I want to run which is UseKit?
I agree. Here's the link:
subject: classpath for jar file K&B
It's not a secret anymore!