GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing javaevolved.dev — Single-file execution | java.evolved
Tooling
Beginner
Single-file executionRun single-file Java programs directly without javac. Code Comparison
✕ 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
See a problem with this code? Let us know.
Why the modern way wins
⚡
One commandjava File.java compiles and runs in one step. 📝
Script-likeAdd a shebang line to make .java files executable scripts. 🎓
Learning-friendlyNewcomers run code immediately without learning build tools. Old Approach
Two-Step Compile
Modern Approach
Direct Launch
Since JDK
11
Difficulty
Beginner
JDK Support
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. Related Documentation
Related patterns
Tooling
Intermediate
Multi-file source launcherJava 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
JDK 22+
→
Tooling
Advanced
Compact object headersJava 8
// Default: 128-bit object header // = 16 bytes overhead per object // A boolean field object = 32 bytes! // Mark word (64) + Klass pointer (64) Java 25
// -XX:+UseCompactObjectHeaders // 64-bit object header // = 8 bytes overhead per object // 50% less header memory // More objects fit in cache
JDK 25+
→
Tooling
Intermediate
JFR for profilingJava 8
// Install VisualVM / YourKit / JProfiler // Attach to running process // Configure sampling // Export and analyze // External tool required Java 9+
// Start with profiling enabled
$ java -XX:StartFlightRecording=
filename=rec.jfr MyApp
// Or attach to running app:
$ jcmd <pid> JFR.start
JDK 9+
→
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |