package pkg1;
public class demoFile1 {
private int maze = 5;
public demoFile1() {}
public demoFile1 (int maze) {
this.maze = maze;
System.out.println(this.maze);
}
}
package pkg2;
import pkg1.*;
public class demoFile2 {
public static void main (String[] args) {
demoFile1 obj = new demoFile1 (10);
}
}
Here, I have created two packages pkg1 and pkg2. In pkg1, there is a class and another class inside pkg2 which imports the pkg1 to initailize the former class, hence it needs to import the .class from pkg1, this produces an error when tried to call from within this sub-directory:
error: package pkg1 does not exist
Please note that the program worked just fine when the pkg1.demoFile1.class file was imported by demoFile2.class from outside that sub-directory (different levels, without confining under pkg2) but, not when both these packages were on the same level, each having source code files and .class files i.e., when pkg2.demoFile2.class tries to import pkg1.demoFile1.class
Edit#1 : Folder Structure: click here
What I feel is that there may have been some issue with hierarchical ordering/precedence while creating or importing the .class file from the package OR the overall definition(s) would have been written wrong. Please help.