Free Online Java Playground
Write Java code and run it, with the output shown in a console. Your code is sent to a free online service to be compiled and run.
Press Run, or Ctrl or Cmd + Enter, to run your code. The output is shown in Console. Java runs on a remote server, so it needs a connection, can be busy, and can take several seconds to answer. Declare the class without public, as in class Main. It stops after 90 seconds. Input is not available.
Preview
Console
Output appears here. Press Run, then try console.log("Hello")
As with any online tool, we highly recommend not including sensitive data in your code, such as passwords, API keys or other secrets.
How to use
Write your code in Main.java. Declare the class as class Main, without the word public, and give it a main method.
Press Run, or Ctrl or Cmd + Enter. The output appears in the Console panel.
Compiler errors and exception stack traces are shown in the console.
Keep sample values in the code, because System.in has no keyboard input to read.
Download a zip with Main.java and a page that records the last output.
Why use this tool
A recent OpenJDK
The newest OpenJDK release the service lists is chosen at each run, and its name is shown with the result.
One file
Put helper classes, records, enums and interfaces in the same file as your main class.
Starter program
The example shows records, streams, collectors and switch expressions.
About this tool
Run a Java program online without installing a JDK or creating a project. The starter code declares a record, filters and sorts a list with the Stream API and uses a switch expression, so you can try modern Java features straight away. Java cannot run inside this page, so when you press Run your code is sent to a free online code-running service, which compiles it with OpenJDK and returns the output. Never paste passwords, API keys or other secrets.
Frequently asked questions
Yes. When you press Run, your code is sent from your browser to Wandbox (wandbox.org), a free community service that runs it and sends back the output. Like any website, it also receives your IP address. Do not include passwords, API keys, private data or other secrets.
Your code is saved as a single file with a different name, and Java allows a public class only in a file with the same name as the class. Remove the word public, as in class Main.
No. You can use the classes that come with the JDK, such as java.util and java.time. Outside libraries cannot be added.
There is no keyboard input, so a Scanner on System.in finds nothing to read. Create a Scanner from a string in your code to test your parsing.
Usually several seconds. The playground stops waiting after 90 seconds. If the service cannot be reached, you see a message and can try again.