Java playground
Compile and run Java in your browser, without installing the JDK: one class per file, as in FP2, autocomplete with the methods of your classes and of String or ArrayList, and the compile error highlighted on its line. It is the environment of the website’s practical mock exams, now free for your own tests and exercises.
How to use it
- Files: one tab per class. + creates a new one; the pencil (or a double click on its name) renames it and the cross deletes it (it asks for a second click). The classes see each other without
import, as if they were in the same package. - Run compiles every file and runs the
mainof the open file; if that one has nomain, the one of another class. If it does not compile, the error appears in the Console with its file and line, which is highlighted in the editor. - Input: what
Scannerwill read, one line pernextLine(). It is not interactive: type the data before running. - Your code is saved automatically in this browser. Download gives you the open class and .zip all of them, ready to open in IntelliJ or VS Code. Upload adds your own
.javafiles. - Share creates a link with your code inside: whoever opens it sees your classes exactly as they are. The code travels inside the link itself; nothing is stored on the website.
- Back to the sample restores the original classes (it asks for a second click). The expand button (top right) makes the environment fill the window and A− / A+ change the text size.
Keyboard shortcuts
| Shortcut | What it does |
|---|---|
| Ctrl + Enter | Compiles and runs |
| Ctrl + Space | Shows the suggestions (sout writes System.out.println, main the main method and fori a for loop) |
| Tab or Enter | Accepts the highlighted suggestion |
| Ctrl + / | Comments or uncomments the selected lines |
| Ctrl + F | Find and replace |
| Ctrl + Z and Ctrl + Shift + Z | Undo and redo |
On a Mac, Cmd instead of Ctrl.
What you can and cannot do
- It compiles with javac (OpenJDK’s) and runs with TeaVM, all in WebAssembly inside your browser. You have everything in FP2: classes, inheritance, interfaces, exceptions,
String,StringBuilder,Scanner,ArrayList,HashMapand the other collections. - The standard library is not complete: there are no threads, no files and no graphical interface.
- An uncaught
NullPointerException, an index outside an array or an infinite recursion stop the program, and the browser does not give the line: the environment tells you which exception it was. - The output appears when the program finishes, not while it runs. Each run can last at most 15 seconds.
- The first time it downloads about 8 MB (the loading bar shows how it is going); after that it starts at once.
Practise with it
- The exercises with solutions of Java in FP2: copy the statement, program it here and compare with the solution.
- The solved programs: paste one, change it and see what happens.
- If you are also learning Python, there is the Python playground, and more will arrive in Playgrounds.

What is an operating system — theory with your laptop on a study afternoon, a write() call and a CPU that never rests (and the three programs that weren’t running at the same time)