Online Java Compiler
Compile and run Java online with OpenJDK 11. Write your program in Main.java, press Run, and it is compiled with javac and started with java, with errors and output shown beside your code. Read keyboard input with Scanner as the program runs.
How to run Java code online
- This page opens with Java selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
OpenJDK 11 on Online IDE
- The file is Main.java, so its public class must be called Main and hold the main method.
- Your code is compiled with javac and run with java, the same two steps as on your own computer.
- Read input with Scanner(System.in) and type it in the output panel while the program runs.
Example: a Java program that reads input
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = in.nextInt();
System.out.println("In ten years you will be " + (age + 10) + ".");
}
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Java version does Online IDE use?
OpenJDK 11. Features up to Java 11, such as var for local variables, work. Records and text blocks need a newer Java and are not available yet.
Why must my class be called Main?
Java requires a public class to live in a file of the same name. The project file is Main.java, so the public class with your main method must be Main.
Can my Java program read input?
Yes. Use Scanner or BufferedReader on System.in, then type into the output panel when the program waits and press Enter.
More Java tools
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.