I wrote two classes in java, f1 is compiling but f2 is not compiling and giving error f1 symbol not found.
f1 class
package x;
public class f1 {
public void printf1() {
System.out.println("First Class");
}
}
The above class is compiling without error,
f2 class
package x;
public class f2 {
public static void main(String[] s) {
f1 f= new f1();
f.printf1()
}
}
How I can try javac -d or javaw for this code.
So here in your case both f1 and f2 ideally should be placed in the same directory, as they are of the same package.
f2 includes the main method. So to execute this program, you'd need compile f2.
If you do it like:
javac f2.java
This would give error f1 symbol not found
, as f2 reference f1, and f1.class is not in the classpath.
So you could do:
javac f2.java f1.java
java f1