Java 25 features

Write Java without public static void main

Compact source files and instance main methods: the smallest Java program is now three lines.

CompactHello.java GitHub
void main() {
    IO.println("Hello, Java 25!");
}

Run with JDK 25: java CompactHello.java

Java 25 finalizes compact source files and instance main methods. A beginner no longer has to meet classes, public, static and String[] on day one.

Before and after

BeforeJava 25
Class declarationRequiredOptional
main signaturepublic static void main(String[] args)void main()
Print to consoleSystem.out.printlnIO.println
Run itjavac then javajava Hello.java

Output

Hello, Java 25!

When to use it

Every example on java25.com is a single file you can run with java FileName.java on JDK 25.