โ— Shell
clean mode source โ†—

Multi-file source launcher

Code Comparison

$ javac *.java
$ java Main
// Must compile all files first
// Need a build tool for dependencies
$ java Main.java
// Automatically finds and compiles
// other source files referenced
// by Main.java

Why the modern way wins

๐Ÿš€

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

JDK Support

Multi-file source launcher

Available

Available since JDK 22 (March 2024)

How it works

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.

Related Documentation