Tooling Intermediate

Launch multi-file programs without an explicit compile step.

โœ• Java 8
$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
โœ“ Java 22+
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java
See a problem with this code? Let us know.
๐Ÿš€

Zero setup

No build tool needed for small multi-file programs.

๐Ÿ”—

Auto-resolve

Referenced classes are found and compiled automatically.

๐Ÿ“

Script-like

Run multi-file programs like scripts.

Old Approach
Compile All First
Modern Approach
Source Launcher
Since JDK
22
Difficulty
Intermediate
Multi-file source launcher
Available

Available since JDK 22 (March 2024)

Java 22+ can automatically compile referenced source files when launching from a .java file. This makes small multi-file programs as easy to run as scripts, without needing Maven or Gradle.

Share ๐• ๐Ÿฆ‹ in โฌก