Skip to content

Playground

Java playground

This runs the real OpenJDK javac, compiled to WebAssembly, so the errors you see are the errors javac actually produces. Your code is compiled and then run entirely inside this tab. How the sandbox works, and its honest limits, is on the code execution and security page.

OpenJDK javac via TeaVM (2026-09-12 build, a subset of the class library)

What this runtime cannot do

It is a real compiler but not a full JVM, and the honest version of that is worth knowing before you hit it:

  • No input. There is no Scanner and no standard input — put your values in the code.
  • Runtime errors are not catchable. Dividing by zero, running off the end of an array or using a null reference stops the program outright instead of throwing something a catch can hold. Exceptions you throw yourself work normally.
  • e.getMessage() is unavailable — use e.toString() instead.
  • Threads do nothing. Code that starts one compiles and runs, and simply never executes.
  • No System.exit(), and %f and %n in format strings do not work.

Everything a beginner normally meets does work: classes, methods, arrays, loops, conditionals, collections, generics, records, streams, String handling and Math.

Ctrl/Cmd+Enter to run

Press Esc then Tab to move keyboard focus out of the code editor.

Ready
Output will appear here after you run your code.

Not sure what to type?

A blank editor is the hard place to start. The Java exercises hand you a program that already runs and ask you to change one thing.