Online Java Runner
This page runs beginner Java in your browser. Write a program, press Run, and read the output. It works for classes, loops, arrays, strings, ArrayList and HashMap, and your code is never sent to a server. It is a subset runner, not javac, and the lists below say what it covers.
javac. See the list of supported features below the editor.Press Run (or Ctrl/Cmd+Enter).What the runner supports
| Area | Supported |
|---|---|
Program shape | A class with public static void main(String[] args), extra classes in the same file, static nested classes, constructors, fields, static and instance methods, overloads, varargs. |
Types | int, long, double, boolean, char, byte, short, String, arrays (including 2D), var. Integer overflow wraps like Java. |
Statements | if, for, enhanced for, while, do, switch (classic and arrow form), break and continue with labels, try, catch, finally, throw, ternary, instanceof with a binding. |
Inheritance | extends, super calls, method overriding, abstract classes, custom exceptions that extend Exception or RuntimeException. |
Library | System.out, String and StringBuilder, Math, Integer, Long, Double, Character, Arrays, Collections (sort, reverse, max, min), ArrayList, LinkedList (as a list), HashMap, HashSet, Scanner on System.in, String.format and printf. |
Exceptions | ArithmeticException, ArrayIndexOutOfBoundsException, NullPointerException, NumberFormatException, StackOverflowError and the other common ones, with Java-style messages. |
What it does not support
- Lambdas, method references and streams
- Interfaces, enums, records, generic classes, anonymous and inner (non-static) classes
- Threads, files, networking, reflection and any import outside java.util, java.io, java.math and java.lang
- TreeMap, LinkedHashMap, PriorityQueue, ArrayDeque, Random
- Sorting with a comparator
- A full type checker: some errors that javac reports at compile time show up here only when the line runs
When a program uses one of these, the runner stops and names the feature. Some details still differ from the JDK, such as the print order of objects that have no hashCode and string == on values built at run time.
How to use it
1. Write or pick a program
Type Java into the editor, or choose an example from the list.
2. Add input if it reads any
If the program uses Scanner, type its input in the stdin box first.
3. Press Run
The program runs in your browser. Output and errors appear below the editor.
4. Stop a long run
Press Stop at any time. The runner also stops a program after 5 seconds or 5 million operations.
Common questions
Is this a real Java compiler?
No. It is a runner written in TypeScript that reads Java source and runs it in your browser. It does not call javac and it does not produce bytecode. It covers the Java that most beginner programs use. A program that uses lambdas, interfaces or streams will stop with a message that names the unsupported feature.
Does my code leave my device?
No. The program runs in a Web Worker in your own browser tab. The page has no server that receives code. The runner gives your program no way to reach the network, and it stops a program that runs for more than 5 seconds.
Why does a program that works on my computer fail here?
It probably uses a feature in the unsupported list above, such as a lambda, an interface or TreeMap. The error message names the feature and the line. For full Java, use a local JDK or a server-based compiler.
Will the output match real Java?
For supported programs it is meant to. The runner is tested against the output of OpenJDK 21 on 38 programs, including integer overflow, HashMap print order, printf rounding and Double.toString. Error messages for compile errors are written for this runner, and they differ from javac.
Can I read input from the keyboard?
Yes, with Scanner on System.in. Type the input into the stdin box before you press Run, because the program reads it all at once.