โ— Shell
clean mode source โ†—

Module import declarations

Code Comparison

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;
import module java.base;

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

Why the modern way wins

๐Ÿงน

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

JDK Support

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.

Related Documentation

Proof