I have created a project with the Maven directory structure and made a package folder called machine in src/main/java/machine.
In the class source file src/main/java/machine/MyClass.java I have defined the package as follows at the top of the file:
package main.java.machine;
However, when I try to compile my Main.java file which is outside of the package with the statement
import main.java.machine.MyClass;
I get a compile error "symbol not found" when i try to instantiate an object from MyClass.
I don't understand how I can follow the naming convention of naming packages after their directory path, while at the same time naming them after the enclosing folder (in my case that would be package machine;, which works).
I tried doing the same thing in a real Maven project with IntelliJ IDEA, and the IDE prompts me to either create a new package folder with the name java.machine.MyClass or rename the package to machine in the statement at the top of the MyClass.java file.
Thanks a lot