E106: Package Name Already Defined
This error is emitted when a top-level definition (such as an object or class) has the same name as an existing package symbol.
The compiler message indicates:
- The name is already used by a package
- The definition cannot coexist with a package of the same name
This error typically occurs in incremental compilation scenarios where:
- A classfile exists defining a symbol with a certain name
- Source code attempts to define a package with the same name
- The conflict between the classfile and the package definition triggers this error
Reproducing this error with simple source code is difficult as it requires specific classpath and compilation order conditions.
To resolve this error, either:
- Rename the top-level definition to avoid the conflict
- Delete the conflicting classfile
- Reorganize your package structure
In this article