| Author |
Doubt in classpath statement....
|
sunil langeh
Ranch Hand
Joined: Sep 04, 2007
Posts: 85
|
|
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: 85
|
|
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: 85
|
|
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
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
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
|
 |
 |
|
|
subject: Doubt in classpath statement....
|
|
|