JeanieJ JeanieJ - 1 year ago 99
Java Question

Struggling to understand workflow for Java files

I am struggling to understand the workflow when you have multiple Java files.

package x;
class myNode {
private myNode next = null;
private int d;
myNode(int d) {
this.d = d;
void append(int d) {
myNode curr = this;
while ( != null) {
curr =;
} = new myNode(d);

package x;
class myMain {
public static void main() {
myNode x = new myNode(1);

I get the following error message when I try to compile

error: cannot find symbol
myNode x = new myNode(1);
symbol: class myNode
location: class myMain

Answer Source

You have been told that java classes can be accessed from other java classes without having to explicitly import them if they are in the same package. That's true. But that's not the whole story.

javac will not try to access a java file that you did not explicitly tell it to access. So, when you try to compile with javac you have to specify in the command line all of the files to be compiled, like this: javac

Also, please note that the convention in java is to use capital first letter for class names.