I'm new to Java, so if the code looks overly silly, please bear with me. :-)
What I'm trying to achieve is simple: Define two classes ClassA
and ClassB
, which are both part of the same package find_class
(this is also the name of the directory where the classes are.
So my files are as follows.
ClassA.java
package find_class;
public class ClassA {
public void func() {
}
}
ClassB.java
package find_class;
import find_class.ClassA;
public class ClassB {
public static void main(String[] args) {
ClassA a = new ClassA();
}
}
When I compile ClassB
, I run into a number of errors:
find_class$ javac ClassB.java
ClassB.java:3: error: cannot find symbol
import find_class.ClassA;
^
symbol: class ClassA
location: package find_class
ClassB.java:7: error: cannot find symbol
ClassA a = new ClassA();
^
symbol: class ClassA
location: class ClassB
ClassB.java:7: error: cannot find symbol
ClassA a = new ClassA();
^
symbol: class ClassA
location: class ClassB
3 errors
I'm not using any IDE and the directory structure is as follows:
find_class
- ClassA.java
- ClassB.java
What am I doing wrong?