A module import declaration makes public types in exported packages available for source-level name resolution; it does not replace module readability or deployment configuration.
Java 25 module imports: source names without a deployment shortcut
Java 25+. The program uses JDK classes and requires no preview flags.
Import names and resolve dependencies separately
The program imports the java.base module and uses several exported types without individual package imports. It remains an ordinary class-path application. Nothing in this source creates a module descriptor for the application or packages a missing external library.
An import can expose many simple names, so collisions need deliberate qualification. Date from java.util and Date from java.sql are different types. Importing more packages does not make those names interchangeable or choose the desired business meaning.
Module import declarations are a Java 25 language feature. An IDE accepting the syntax with a newer SDK does not prove that a Java 21 build target can compile it. Keep the compiler release and the application’s required runtime in the build definition.
Keep the dependency visible to reviewers
For a small file, individual imports can make dependencies easier to read. A module import is useful where the module is the intended source namespace. That choice is about source organization; it is not a claim that every exported class is loaded into memory at startup.
Working program
import module java.base;
public class ModuleImportedReceipts {
public static void main(String[] args){
List<String> references=List.of("R-23","R-11","R-23");
Set<String> unique=new TreeSet<>(references);
System.out.println(unique);
System.out.println(LocalDate.of(2026,9,29));
}
}Output
[R-11, R-23]
2026-09-29Costs and boundaries
The list and tree operations determine this program’s runtime cost. Import syntax affects source name resolution and does not promise shorter startup, a smaller artifact, or automatic library discovery. A named application module still needs its descriptor and launch configuration.
Common Mistakes
- An import is not a requires declaration.
- Ambiguous simple names still need qualification.
- The selected module must be observable under the compilation setup.
