OpenJDK 21 (LTS)

Online Java Compiler

Compile and run Java code online with OpenJDK, OOP principles and Scanner stdin. Write code with auto-formatting, test with standard input (stdin), and inspect terminal output in real-time.

✓ Modern Java 21 LTS language syntax✓ Classes, interfaces, records, and pattern matching✓ Standard collections and stream API✓ Interactive Scanner standard input
Main.java
OpenJDK 21 (LTS)
13px
Standard Input (stdin)
Passed to scanf, input(), cin, etc.
UTF-8Java (OpenJDK)2 SpacesWrap: Off
Ctrl+Enter to Run
Ln 1, Col 126 lines896 chars
Output & ConsoleIdle

Ready to Compile & Run

Click the blue ▶ Run button in the header bar or press Ctrl + Enter to compile and execute your Online Java Compiler.

How to Run Java (OpenJDK) Code Online

Develop, compile, and execute Java programs online with full object-oriented programming support.

  1. Keep the public class named "Main" containing the public static void main method.
  2. Enter any required input in the Stdin tab.
  3. Press "▶ Run" or Ctrl + Enter.

Common Errors & Troubleshooting

Encountering compilation or runtime diagnostics? Check these common scenarios:

class X is public, should be declared in a file named X.javaKeep the main class named "Main" (public class Main).

Related Popular Language Compilers

View all 35+ compilers →
Python 3.py

Write, run and test Python 3 code in your browser with interactive standard input

JavaScript (Node.js).js

Execute modern ES6+ JavaScript code in an isolated high-speed runtime

TypeScript.ts

Type-safe JavaScript playground with instant transpilation and type validation

HTML / CSS / JS.html

Multi-pane web editor with live preview, responsive device frames and instant rendering

Frequently Asked Questions (Java (OpenJDK))

The automated Java runner builds Main.java as the entry point class.