Multi-file source launcher
Launch multi-file programs without an explicit compile step.
Code Comparison
✕ 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
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
Since JDK
22
Difficulty
intermediate
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.