Multi-file source launcher
Launch multi-file programs without an explicit compile step.
Porównanie kodu
✕ 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
Widzisz problem z tym kodem? Daj nam znać.
Dlaczego nowoczesne podejście wygrywa
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.
Stare podejście
Compile All First
Nowoczesne podejście
Source Launcher
Od JDK
22
Poziom trudności
Średniozaawansowany
Wsparcie JDK
Multi-file source launcher
Dostępne
Available since JDK 22 (March 2024)
Jak to działa
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.
Powiązana dokumentacja