No, the unnamed package is not imported by the compiler.
Please note the following from the Java Language Specification.
From Compilation Units:
A compilation unit that has no package declaration is part of an unnamed package (§7.4.2).
From Packages:
For small programs and casual development, a package can be unnamed (§7.4.2) or have a simple name, but if code is to be widely distributed, unique package names should be chosen using qualified names. This can prevent the conflicts that would otherwise occur if two development groups happened to pick the same package name and these packages were later to be used in a single program.
From Observability of a Package:
The packages java
, java.lang
, and java.io
are always observable.
Note that the unnamed package is not listed.
From Import Declarations:
A type in an unnamed package (§7.4.2) has no canonical name, so the requirement for a canonical name in every kind of import declaration implies that (a) types in an unnamed package cannot be imported, and (b) static
members of types in an unnamed package cannot be imported. As such, §7.5.1, §7.5.2, §7.5.3, and §7.5.4 all require a compile-time error on any attempt to import a type (or static
member thereof) in an unnamed package.