aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "classpath for jar file K&B" Watch "classpath for jar file K&B" New topic
Author

classpath for jar file K&B

Ferwed Kondos
Greenhorn

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

And the following sub-directory structure:

test
|--UseKit.class
|
com
|--KitJar.jar

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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.


Henry


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

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: http://aspose.com/file-tools
 
subject: classpath for jar file K&B