The purpose of Java packages is to give structure to your project. A structure helps to mentally break down a project into smaller parts, simplifying readers' understanding of how components are connected and how they interact.
By convention, the source files' directory structure should replicate the project’s package structure. This is for the following reasons:
Similarly, a source directory should not have the character .
in its name, as this would make it impossible to match the directory to
the package structure.
Either move the source file so that the relative file path within the source directory matches the package name, or change the package name so that it matches the relative file path.
// file: src/main/foo/Fubar.java package com.foo.bar; class Fubar { }
// file: src/main/com/foo/bar/Fubar.java package com.foo.bar; class Fubar { }
// file: src/main/foo/Fubar.java package foo; class Fubar { }