Online Java compiler (Java 21)
Write code, add input, press Run. Free, no sign-up — your code stays in this browser.
Java editor
Output
Press Run to see your program’s output here.
Tips for Java
- Your public class must be named Main.
- Read input with Scanner (simple) or BufferedReader (fast).
- Standard library only.
Frequently asked questions
- Is this online Java compiler free?
- Yes. Compile and run Java 21 programs here for free without signing up.
- Why must the class be called Main?
- The runner compiles your file as Main.java and runs the Main class, so your public class must be named Main.
- How do I read input in Java?
- Type the input in the Input box and read it with Scanner sc = new Scanner(System.in); then sc.nextInt(), sc.next() or sc.nextLine().
- Which Java version is used?
- Java 21, so modern features such as records, var and switch expressions work.