I have this directory structure:
project1/src/edu/course/firstweek/javacourse/Program1.java
Another file in one package above:
project1/src/edu/course/firstweek/program2.java
In the header of program2.java, I have
package edu.course.firstweek;
import edu.course.firstweek.javacourse.Program1;
Now to when I run the following in commandline:
Javac src/edu/course/firstweek/program2.java,
I get this error:
src/edu/course/firstweek/program2.java:14:error cannot find symbol
System.out.println(program1.print("hello world"));
symbol: variable Program1
location: class program2
2 errors
I can see that the compiler is not able to find the program1
,but I have the correct import
package
statement in program2
. I need help here and after compiling, is there something that needs to be taken into account for running the program.
Thanks
Try going into one directory inside, i.e.
cd src
and then compileJavac edu/course/firstweek/program2.java
for running, do
java edu.course.firstweek.program2