KB book Q-3 Self test
OCPJP 6.0 93%
OCPJWCD 5.0 98%
1.A option,B option gives the following compile time error:
cannot find symbol A
as far i know javac looks in the current directory by default.Then why such error
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
It does search in the current directory but it will look for A.class in xcom directory in the current directory. Since you are already in the xcom directory, it will try to find /test/xcom/xcom/A.class which is not there so you get an error.
OCPJP 6.0 93%
OCPJWCD 5.0 98%
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
OCPJP 6.0 93%
OCPJWCD 5.0 98%
mohitkumar gupta wrote:1.Does -cp looks only for class files ?
2.Is it that javac looks for class files and java files in the current directory and java doesnot ?
Why would
javac B.java
doesnot run ?
why would it search xcom/A.class in /test/xcom/ ?
As A.class resides in xcom then,why is it no able to find it ?
javac -classpath . B.java
this statement says look in the current directory(xcom) for the file B.java and since B.java needs A.java,i think it could be found easily as it is in the xcom directory.
javac -classpath xcom B.java
javac -classpath xcom:. B.java
it would not work since current directory is test and test contains xcom and not B.java.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
but ,i have one more doubt that i am specifying xcom in the classpath,then why it would not able to find A.class and B.java
is it that classpath only looks for .class files only.it would find A.class but not B.java ?
OCPJP 6.0 93%
OCPJWCD 5.0 98%