Paste the snippet above (or your own Java code) and run it there — real compilation, real output.
Why this links out instead of embedding
Java compiles to bytecode that then runs on a JVM — a full virtual machine that isn't something a browser tab can spin up on its own. Rather than approximate that with a partial JavaScript reimplementation, this links to Compiler Explorer, which runs a real javac and JVM on its own servers and streams back genuine output.
About Compiler Explorer
Compiler Explorer started in 2012 as a tool for visualizing how C++ compiles to assembly, and has since grown to support Java, Go, Rust, Swift, Python, and 30+ other languages, performing around 3 million compilations a week. It's open source, widely used across the industry for teaching and compiler research, and lets you switch between multiple JDK versions and see compiler diagnostics in real time.
What to try next
- Java language reference — 30 topic pages
- Java snippets — copy-ready idiomatic patterns
- Learn Java — structured lessons