XCODX |

Java Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Java

Every AP Computer Science A exam and countless university CS1/CS2 sequences are taught in Java, and the language is just as entrenched in industry — Amazon, Netflix's backend, and nearly every major bank run critical systems on the JVM. Modern Java is far more expressive than its old reputation suggests: records, pattern matching for switch, text blocks, and virtual threads have all landed in recent LTS releases. This online Java compiler pairs a modern JDK with a real interactive terminal, meaning Scanner and System.in behave exactly as they do in IntelliJ or a local shell — your program prints its prompt, then sits and waits for you to type.

Hello World in Java

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int n = sc.nextInt();

        long fact = 1;
        for (int i = 2; i <= n; i++) {
            fact *= i;
        }

        System.out.printf("%d! = %d%n", n, fact);
        sc.close();
    }
}

When to use Java

Run AP Computer Science A practice problems and university OOP assignments without wrestling with JDK installs or IDE licensing, solve LeetCode and HackerRank problems in the language most big-tech interview loops still accept by default, or confirm exactly what a String method, ArrayList operation, or integer overflow does before an exam. Because Scanner works against a live terminal, textbook exercises that read input interactively run unmodified — the same code your professor demonstrates in class works here verbatim.

Common questions

Does Scanner with System.in work in this online Java compiler?

Fully. The sandbox attaches your program to a real terminal, so sc.nextInt(), sc.nextLine(), and hasNext() loops block for live keyboard input exactly like a local console application. You don't pre-load input into a text box — the program prompts, you answer, it continues.

Which JDK version compiles my code?

A modern LTS-line JDK, so contemporary language features — var, records, enhanced switch expressions, text blocks, and the streams API — compile and run. If you're studying from an older textbook, all legacy syntax remains valid too; Java's backward compatibility is famously strict.

Can I use Maven or Gradle dependencies here?

No — there's no dependency resolution in the sandbox, so external libraries like Gson, JUnit, or Apache Commons aren't available. Everything in the JDK itself is: collections, java.time, regex, concurrency utilities, and I/O. Your code should live in a single file with one public class.

How Java runs on XCODX

Sandbox filename
Main.java
Entry point
Main class entrypoint
Editor grammar
text/x-java
Reading stdin
new Scanner(System.in)
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello from Java!");
        System.out.println("Welcome to XCODX Online Compiler!");
    }
}

JVM notices such as "Picked up JAVA_TOOL_OPTIONS" and unchecked-operation notes are filtered from the output pane.