Java
Online Java IDE
A project gives Java what a single playground can’t: folders, so package shop lives in shop/Cart.java the way javac expects, beside data files and uploads, all saved to your account. Each project keeps its own Java version, 8 to 25, in Project details.
Try it aboveHow Java runs here
- Versions
- Java 8, 11, 17, 21 (default), 25 (OpenJDK, Eclipse Temurin)
- Build
javac Main.java- Run
java -Xmx384m Main- Limits per run
- 512 MB memory, 15 s of CPU time on 2 cores, 2 MB of output
- Time
- Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
- Sandbox
- Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.
- Good to know
- The heap is capped at 384 MB.
Packages in folders
Main.java shop/Cart.java
// shop/Cart.java package shop; import java.util.ArrayList; import java.util.List; public class Cart { private record Line(String name, int qty, double price) {} private final List<Line> lines = new ArrayList<>(); public void add(String name, int qty, double price) { lines.add(new Line(name, qty, price)); } public double total() { return lines.stream().mapToDouble(l -> l.qty() * l.price()).sum(); } } // Main.java import shop.Cart; public class Main { public static void main(String[] args) { Cart cart = new Cart(); cart.add("Notebook", 2, 3.50); cart.add("Pen", 3, 1.20); System.out.printf("Total: %.2f%n", cart.total()); } }
$ java -Xmx384m Main Total: 10.60
- javac Main.java finds shop.Cart in shop/Cart.java on its own, because it looks for the classes Main uses in folders named after their packages. No Maven or Gradle file is needed.
- Keep Main.java at the top of the project. Run starts the class named after the file, so choose Run this file by default in Main.java’s menu in the file tree to run it from any tab.
- Compiled .class files stay out of the file tree, so the project holds only your sources.
Working in a Java project
- Ctrl+P opens a file by typing part of its name (cart finds shop/Cart.java), Ctrl+B shows or hides the file tree, Alt+W closes the open file, and F2 or Del renames or deletes the file selected in the tree.
- Upload input files into any folder and read them with a path from the top of the project: Files.readAllLines(Path.of("data/input.txt")).
- Files the program writes, in any folder, are added to the project after the run, so a report written to out/report.txt appears in the tree.
- Download the project as a .zip of plain .java files and folders.
What a Java project doesn’t have
- Dependencies: a pom.xml or build.gradle is just a file here, and an uploaded .jar isn’t on the class path. Code can use only the JDK.
- A debugger: stepping through code is for Python only. Print to System.err, whose lines show in red, to trace a value.
- assert checks: the run command doesn’t pass -ea, so assert statements are skipped.
- Java-aware completion: the editor suggests words from the open file, not methods of a class.
Plans for Java projects
- Free accounts get 3 public projects of up to 3 MB. Basic allows unlimited private projects of up to 25 MB, shared with people you choose, and forking; Premium raises the size to 100 MB (see Pricing).
- Premium starts a Linux session per project with a terminal that keeps running. There, run Main.java compiles and runs the file the way the Run button does, and you can call javac and java yourself, for instance java -ea Main to turn assert checks on.
- On Basic and Premium the agent takes a task such as “add a discount method to Cart and test it from main”, edits the files, runs the program, fixes what fails, and shows every change as a diff you can undo.
Questions
Can I use Java packages?
Yes, in a project: put package shop; at the top of shop/Cart.java, and import shop.Cart; in Main.java. The playground has no folders, so packages need a project.
Can I add a JAR or a Maven dependency?
No. The build is plain javac on your sources, with only the JDK’s classes available.
Is there a Java debugger?
No. The step debugger is for Python only; trace Java with System.err.println().
Can I set the Java version for one project?
Yes. Open Project details and pick Java 8, 11, 17, 21 or 25; the project keeps it.
Can students fork my Java project?
Forking a project is on paid plans. On any plan, a playground Share link gives each student a copy they can run and change.