Module imports go final

Java 25 Course · lesson 4 of 16 · 3 min read

One import line for a whole module, now supported rather than preview.

Open this lesson in the learning hub

Key points

  • JEP 511 finalises import module java.base; - every package that module exports becomes visible.
  • It pairs naturally with compact source files: a short script with no import block at all.
  • Encapsulation is untouched - you still only see packages the module actually exports.
  • If two imported modules export the same simple name, that name is ambiguous and you import it explicitly.
  • For large codebases, explicit imports are still usually clearer about where a type comes from.

Module imports cut ceremony for small programs; big codebases still benefit from explicit imports.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Java 25 Course course, and every lesson in it is listed on the Java 25 Course contents page.