Tooling beginner

Single-file execution

Run single-file Java programs directly without javac.

✕ Java 8
$ javac HelloWorld.java
$ java HelloWorld
// Two steps every time
✓ Java 11+
$ java HelloWorld.java
// Compiles and runs in one step
// Also works with shebangs:
#!/usr/bin/java --source 25

One command

java File.java compiles and runs in one step.

📝

Script-like

Add a shebang line to make .java files executable scripts.

🎓

Learning-friendly

Newcomers run code immediately without learning build tools.

Old Approach
Two-Step Compile
Modern Approach
Direct Launch
Since JDK
11
Difficulty
beginner
Single-file execution
Available

Widely available since JDK 11 (Sept 2018)

How it works

The Java launcher can compile and run a single source file in one command. Combined with shebang support on Unix, Java files can work as scripts. No separate compilation step needed.

Share 𝕏 🦋 in