Language intermediate

Module import declarations

Import all exported packages of a module with a single declaration.

✕ Java 8
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
✓ Java 25+
import module java.base;

// All of java.util, java.io, java.nio
// etc. available in one line
🧹

One line

Replace a wall of imports with a single module import.

📦

Module-aware

Leverages the module system to import coherent sets of packages.

🚀

Quick starts

Perfect for scripts and prototypes where import lists are tedious.

Old Approach
Many Imports
Modern Approach
import module
Since JDK
25
Difficulty
intermediate
Module import declarations
Available

Finalized in JDK 25 LTS (JEP 511, Sept 2025).

How it works

Module import declarations let you import everything a module exports with one line. This is especially useful for java.base which covers collections, I/O, streams, and more.

Share 𝕏 🦋 in