I am reading java certification book and here is the question from the book. Please have a look at the following directory structure shown in picture.
Here is the source code for A.class and B.java
package xcom;
public class A{}
package xcom;
public class B extends A{}
Which allows B.java to compile.
- Set the current directory to test then invoke javac -classpath . xcom/B.java
- Set the current directory to test then invoke javac -classpath xcom B.java
- Set the current directory to test and then invoke javac -classpath xcom:. B.java
It says option 1 is correct and its actually compiling as well. My point is that basically in order for B.java to compile, it needs to find A.class. We are in directory test and when we say -classpath ., it searches for files in current directory. But A.class is not present in current directory. Can someone explain this concept to me?
Thanks, Ben