File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in classpath statement.... 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 in classpath statement...." Watch "Doubt in classpath statement...." New topic
Author

Doubt in classpath statement....

sunil langeh
Ranch Hand

Joined: Sep 04, 2007
Posts: 88

Ans. is C
Why not others like B, E? (Got from - K&B)


Thanks
Sunil (SCJP 5)
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Sunil.

The top level of package should be directly under classpath . ( thats wat I would always prefer) , so test directory must be in classpath to get the copilation successful as xcom is where package starts.


B and E does not include test directory in classpath !!
sunil langeh
Ranch Hand

Joined: Sep 04, 2007
Posts: 88
Balu Sadhasivam wrote:Sunil.

The top level of package should be directly under classpath . ( thats wat I would always prefer) , so test directory must be in classpath to get the copilation successful as xcom is where package starts.


B and E does not include test directory in classpath !!

Thanks Balu for quick reply, but it still not completely clear to me, Would you please elaborate it???
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


OK. For B.java to compile , test directory must be in classpath , wuld you agree to this atleast ? ( which means you agree that C is correct )
sunil langeh
Ranch Hand

Joined: Sep 04, 2007
Posts: 88
Balu Sadhasivam wrote:
OK. For B.java to compile , test directory must be in classpath , wuld you agree to this atleast ? ( which means you agree that C is correct )

Yes, but what about E
E. Set the current directory to test then invoke
javac -classpath xcom:. B.java
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

because B.java is not in the test directory. Classpath is where JVM searches for class files and not java files.

So javac -classpath xcom:. B.java , would search for B.java in current directory which is test

P.s : Wish my Broadband connection is as stable as Java
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

This question has been asked and discussed before in the SCJP forum:

http://www.coderanch.com/t/427256/Programmer-Certification-SCJP/certification/Classpath
http://www.coderanch.com/t/426637/Programmer-Certification-SCJP/certification/Class-path-again
http://www.coderanch.com/t/426283/Programmer-Certification-SCJP/certification/Classpath-setting-involving-java-javac
http://www.coderanch.com/forums/posts/list/40/426145

Please search the forums for "xcom", and you'll find more.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in classpath statement....
 
Similar Threads
Very Much Confused !!!
Plz help me in solving the problem of JAVAC comand
Ch. 10 Development question
Classpath Related Question
Classpath - Question 1