Help me out here. If you are in the xcom directory and the classpath is set to classpath . ,
then when you execute the javac command in the xcom directory, javac should find A.class. Can you tell me what I'm missing?
5. Given the default classpath:
And this directory structure:
And these two files:
Which allows B.java to compile? (Choose all that apply.)
A. Set the current directory to "xcom" then invoke
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
® 3 C is correct. In order for B.java to compile, the compiler first needs to be able to find
B.java. Once it's found B.java it needs to find A.class. Because A.class is in the
xcom package the compiler won't find A.class if it's invoked from the xcom directory.
Remember that the -classpath isn't looking for B.java, it's looking for whatever classes
B.java needs (in this case A.class).
®˚ A, B, and D are incorrect based on the above. E is incorrect because the compiler can't
find B.java. (Objective 7.2)