5.
Given the default classpath:
/foo
And this directory structure:
And these two files:
package xcom;
public class A { }
package xcom;
public class B extends A { }
Which allows B.java to compile? (Choose all that apply.)
A. Set the current directory to xcom then invoke
javac B.java
B. Set the current directory to xcom then invoke
javac -classpath . B.java
C. Set the current directory to test then invoke
javac -classpath . xcom/B.java
D. Set the current directory to test then invoke
javac -classpath xcom B.java
E. Set the current directory to test then invoke
javac -classpath xcom:. B.java
When searching for class files, the java and javac commands don't search the current directory by default.
SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
SCJP 6
-cp path or -classpath path
Specify where to find user class files, and (optionally) annotation processors and source files. This classpath overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, the user class path consists of the current directory.
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 6
Jia Tan wrote:Punit,
I didn't set CLASSPATH on my machine. echo %classpath% simply returns "%classpath%"
SCJP 6
Jia Tan wrote:That's why! Thank you Punit! I was testing K&B original example which has xcom under test, and in that directory there are A.class and B.class! Later I created com/xcom file structure under same test directory, and thing started getting confused! After I remove the xcom under test, everything back to normal.
I am still wondering why my other computer don't accept current dir why I didn't specify -classpath in javac or java, I will do more research on that.
SCJP 6
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|