About this Java playground
This is a Java compiler you can use straight away. Write Java in the editor, press Run, and your program is compiled and run on a real JVM. The output appears next to it: everything it prints, any compiler error with its line number, any exception with its stack trace, and how long it took.
It runs Java 25, the current long-term support release, in an isolated sandbox on our servers, so records, switch expressions and the rest of modern Java behave as they do on your own machine. It is free, with nothing to install and no account needed.
What you can run
- Java 25 (OpenJDK), running one file per run, saved as
Main.java. - Standard library only. The whole Java SE standard library is there: java.util collections such as ArrayList and HashMap, streams, java.time, java.math, java.io, java.nio and the rest. There is no package installer, and programs have no network access.
- Limits: 10 seconds and 256 MB of memory per run. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
- Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.
Reading input
Open the Input box under the editor and type what your program should read. It arrives as standard input, System.in: a Scanner reads it a word, number or line at a time. With the box empty, hasNextLine() returns false and nextLine() throws NoSuchElementException.
Scanner input = new Scanner(System.in); int age = input.nextInt();
Frequently asked questions
Is this online Java compiler free?
Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.
Which version of Java does it run?
Java 25, the current long-term support release (Eclipse Temurin, an OpenJDK build), on Linux. Records, switch expressions, pattern matching, text blocks and var all work, and so do compact source files: a file holding only void main() { IO.println("Hello"); }, with no class around it, runs too.
Does my class have to be called Main?
Not always. The file is saved as Main.java and run with java Main.java, which compiles it in memory and runs the first class in the file, whatever it is called. If that first class has no main method, Java looks for a class called Main instead. So either put the class with main at the top, or call it Main, as the example does. Other classes, records and interfaces can go in the same file.
Can I use libraries from Maven or Gradle?
No. The playground runs one file against the Java standard library. There is no Maven, no Gradle and no network, so there are no dependencies to add, but everything that ships with Java is available.
Why does a run take a couple of seconds?
Each run starts a fresh Java virtual machine, which compiles your file with javac and then runs it, which takes about two seconds for a small program. That time counts towards your program's own limit, so there is no separate compile step to wait for.
Why did my program stop with a time-out?
Each run gets 10 seconds and 256 MB of memory. A program that goes past either is stopped. That includes compiling your file. The usual cause is a loop that never ends, such as a while loop whose condition never turns false.
Is my code saved or shared?
Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.