Java packages serve two purposes:
When no package is explicitly specified for the classes in your project, this makes the project harder to understand and may cause name collisions with other projects. Also, classes located in the default package not be accessed from classes within named packages since Java 1.4.
Move your class to a package directory and explicitly state the package’s name at the top of the class. If your project does not have a package structure, think of a structure that fits your needs. The package names should be unique to your project. You can find some best practices when choosing package names in the Ressources section below.
public class MyClass { /* ... */ } // Noncompliant, no package spacified
package org.example; // Compliant public class MyClass{ /* ... */ }