Online Java compiler
Compile and run Java online free, no sign-up: write a Main class, give it input on stdin and see the output, compiler errors and run time instantly.
How do I run Java code online?
This is an online Java compiler: write a class called Main with a main method, put its input in the Input box and press Run. It is compiled with javac and run on the JVM on the server, and you see the output, the compiler's errors or the exception and its stack trace, and the run time — free, with no sign-up.
How it works
- Write your program. The file is compiled as Main.java and run from the class Main, so the class holding public static void main(String[] args) must be named Main. Other classes can sit in the same file as long as they are not public.
- Give it input. Scanner sc = new Scanner(System.in) with nextInt(), next() and nextLine() is simplest. For large input use BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) and br.readLine(), which is several times faster. Put every line the program reads in the Input box before you run it.
- Run it. Press Run or Ctrl+Enter. You get what the program printed, any compiler or runtime error, and how long it ran. The first run without an account asks a quick check that you are a person.
Who it is for
Anyone writing Java who wants it run now: a student checking a lab program or an exam answer, someone on a machine where nothing can be installed, or a learner trying Java before setting it up.