Online Java compiler

This compiles your Java with a real javac, in the browser. Your code never leaves this tab.

Main.javajavac on TeaVM

Press Run. The javac on TeaVM engine (about 4 MB) downloads once on your first run, then stays cached.

Java · runs in your browser · nothing uploadedLn 1, Col 1

// Free tool

This compiles your Java with a real javac, in the browser - your class is compiled and then executed in the tab, with no JDK installed anywhere and nothing sent to a server. Collections, streams, generics and records all work.

Nothing you type is sent to a server. Your code is saved only in this browser, the engine is downloaded once and cached, and once it has loaded the page keeps running your code with the network off. No account, no sign-in, no limit on how many times you press Run.

// What you get

javac on TeaVM, in a browser tab

A real javac, translated to WebAssembly, compiling your class to a WebAssembly module that then runs in the tab.

What it supports

  • A real javac: generics, records, sealed types, lambdas, streams, switch expressions and text blocks.
  • The collections framework, java.util, java.time, String and the rest of the everyday standard library.
  • Compiler errors with the line number javac gave them.

What it does not

  • Your entry point has to be a class named Main with a public static void main. That is the class the runner invokes.
  • No stdin, and one output stream: System.out and System.err arrive interleaved rather than apart.
  • A NullPointerException, a divide by zero or an array index out of bounds stops the program instead of being thrown, so a try or catch around one never runs. That is a property of compiling Java to WebAssembly, not something the tool chooses.
  • String.format and printf with %f or %g are not supported by this runtime. %d and %s are fine.

// Why it runs here

Your code never leaves the tab

Most online compilers send your code to a server, run it in a container, and send the output back. That means a queue when the site is busy, a hard cap on how long your program may run, and a copy of your code on someone else's disk. This one downloads the compiler instead, once, and runs everything locally from then on.

No upload, no account

  • The compiler is fetched once and cached; your source is never sent anywhere.
  • Nothing is stored on our side. Your code is kept in this browser only, so it is still here when you come back.
  • Once the engine has loaded, it keeps running with the network off, which a hosted sandbox cannot do.

Then practice it for real

  • A runner tells you what your code printed. It cannot tell you whether you have learned anything.
  • Prepshotz runs the same engines against real test cases and grades the result.
  • Practice Java with graded problems →

// Questions

Java in the browser - FAQ

01Do I need a JDK installed?

No. The compiler itself has been translated to WebAssembly and downloads into your browser on the first run, which is the whole point: no JDK, no PATH, no version manager.

02Why does my try or catch not catch a NullPointerException?

Because on this runtime a null dereference, a divide by zero and an out-of-bounds array access stop the program at the WebAssembly level rather than being thrown as Java exceptions. Everything you throw yourself is catchable as normal. It is a real limit of compiling Java this way and we would rather say so than let you debug it.

03Does my code get uploaded anywhere?

No. The compiler runs inside your browser tab, so your code never leaves your machine. There is no server to send it to and nothing is logged on our side. Your code is kept only in this browser, and a share link carries it inside the link itself.

04Is it really free, and do I need an account?

Yes, and no. Every tool here runs without an account, a card, or a sign-in. They are free because they cost us nothing per run: the compiler is downloaded to your browser once and your own machine does the work.

Run Java here. Get graded on it there.

Free while we're in beta.