Compact source files
Write a complete program without class declaration or public static void main.
Code Comparison
✕ Java 8
public class HelloWorld {
public static void main(
String[] args) {
System.out.println(
"Hello, World!");
}
}
✓ Java 25
void main() {
println("Hello, World!");
}
Why the modern way wins
Zero ceremony
No class, no public static void main, no String[] args.
Beginner-friendly
New programmers can write useful code from line 1.
Script-like
Perfect for quick prototypes, scripts, and examples.
Old Approach
Main Class Ceremony
Modern Approach
void main()
Since JDK
25
Difficulty
beginner
JDK Support
Compact source files
Available
Finalized in JDK 25 LTS (JEP 512, Sept 2025).
How it works
Compact source files remove the ceremony of class declarations and the main method signature for simple programs. Combined with implicit import of java.io.IO, even println is available directly.