I have the following two source files
World.java File
package planets;
public class World {
public static void main(String[] args) {
Mars.land();
}
}
Moon.java file
package planets;
public class Moon {
public static void land() {
System.out.println("Hello Moon");
}
}
class Mars {
public static void land() {
System.out.println("Hello Mars");
}
}
As we can see, it Moon.javacontains two classes: an open Moonclass and a non-public class Mars.
The files are inside the directory planets, the directory tree is shown below
+current-dir:
+
+
+
Now, if I try to compile from the Windows command prompt (I'm inside the folder current-dir) by typing
javac planets\World.java
I get this error message:
planets\World.java:5: error: cannot find symbol
Mars.land();
^
symbol: variable Mars
location: class World
1 error
This is very strange because I know that the compiler is looking for non-public classes in all the source files of the current package. Also Cay Horstmann Core Java Vol 1, 10th ed. pp. 192-193 states that:
[...] . . , , , .
, Eclipse Oxygen, . , Eclipse .
javac ?
EDIT: CLASSPATH. .