Online Java Compiler
Write Java on the left and see the result on the right. Compile and run in one click, with real javac errors, Scanner input and the standard library. It runs in your browser, so there is nothing to install and your code is never uploaded.
Input for Scanner / System.in
Scanner, BufferedReader and System.in read from this box. The answers are not echoed in the output.
Ctrl+Enter runs the code, Ctrl+/ comments lines, Tab indents. Press Esc then Tab to leave the editor with the keyboard. Your code is saved in this browser.
Java runs in your browser with CheerpJ by Leaning Technologies.
How to use the Java compiler on KickSolve
Three quick steps, no account needed.
Why choose KickSolve
The real compiler, clear errors and a private editor.
What you can do with this Java compiler
Everything the editor and output panel offer.
About the online Java compiler on KickSolve
What it does and how to get the best results.
What is an online Java compiler?
An online Java compiler lets you write Java in the browser, compile it and run it, without installing the JDK or setting up an IDE. Java is first compiled to bytecode with javac and then executed by the Java virtual machine. People search for a "Java compiler", "Java editor", "Java runner" or "Java playground" when they want exactly this: type code, press Run, see the result.
How your code runs
The tool runs the Java compiler and a Java virtual machine inside your browser, using a project called CheerpJ that is built on WebAssembly. When you press Run, your code is written to a temporary file, compiled with javac, and, if there are no errors, started. Everything printed with System.out and System.err shows up in the output panel. The first time you use it, your browser downloads the Java runtime and the compiler, which is a large download. The browser keeps these files afterwards, so later runs and visits start faster. Each run still needs a few seconds, because the compiler and the program are started one after the other.
Class names and files
Java expects a public class to live in a file with the same name. The tool takes care of this: it finds the public class in your code and saves the file under that name. If there is no public class, it uses Main. To decide which class to start, it uses the public class, or otherwise the class that has a main method. You can write several classes in the editor, but only one of them can be public. A package statement at the top is supported.
Reading input with Scanner
Many beginner programs ask a question with Scanner. Because there is no keyboard prompt in the browser, System.in reads its lines from the Input box under the editor, one line for each value. Scanner, BufferedReader and similar classes all work with it. The answers you type are not echoed in the output, so print your own prompt text if you want to see what was asked.
Errors and what to do about them
If the code does not compile, the compiler errors are shown in red with the file line number, the source line and a marker under the problem, just like javac prints them. Click the line number to jump to that line in the editor. If the program compiles but throws an exception, the stack trace is shown, and the line in your own code is clickable. For common mistakes such as a missing semicolon, an unknown symbol or an endless recursion, the tool adds a short hint.
Java version
The page shows the Java version in the settings bar. Code written for that version works, including generics, lambdas, method references and streams. Features from newer releases, such as var, records, text blocks and switch expressions, only work when the page runs a newer version. If your code uses one of them and fails to compile, the tool points this out.
Limits and privacy
Output is text only: Swing, AWT and JavaFX windows are not shown. Threads and java.util.concurrent work, but network sockets and external libraries from Maven or Gradle do not. Files you create live in a temporary store in your browser. Your code is not uploaded: it is compiled and run on your device and saved only in this browser. Only the Java runtime is downloaded, from the CheerpJ content network, and the compiler from this site. A shared link keeps the code in the part of the address after the # sign, which is not sent to any server.
Read the KickSolve privacy policy for details about the site itself.
What works in this Java compiler
A quick reference for common features.
| Feature | Works? | Notes |
|---|---|---|
| Classes, interfaces, enums, inner and anonymous classes | Yes | Several classes in one editor, only one public |
| Generics, lambdas, method references, Streams | Yes | Part of Java 8 |
| Collections, String, StringBuilder, Math, java.time | Yes | Standard library is included |
| Scanner, BufferedReader, System.in | Yes | Reads from the Input box |
| Threads, ExecutorService, CompletableFuture | Yes | Included |
| Exceptions and stack traces | Yes | Click the line number to jump to your code |
| package statement | Yes | The class is started with its package name |
| var, records, text blocks, switch expressions | Depends | Only on a newer Java version than 8 |
| File I/O | Temporary | Files live in a temporary store in your browser |
| Swing, AWT, JavaFX windows | No | Text output only |
| Sockets, Maven or Gradle dependencies | No | Standard library only |
Online Java compiler vs JDK on your computer vs hosted services
When each is the better choice.
| This compiler | JDK on your computer | Hosted online compilers | |
|---|---|---|---|
| Setup | None, works in the browser | Install the JDK and an editor | None |
| Where code runs | On your device | On your device | On a remote server |
| Startup time | A few seconds per run, large first download | Fastest | Fast, but depends on the server |
| Java version | Fixed by the page | Any you install | Often several |
| Libraries | Standard library | Anything you add | Standard library, some more |
| Best for | Learning, quick tests and private snippets | Real projects | Trying newer Java versions |
Frequently asked questions
Quick answers.
What is an online Java compiler?
It is a web page where you write Java, compile it and run it, with no JDK to install. This one runs the real javac compiler and a Java virtual machine inside your browser, so you see the same compiler errors and program output as on your computer.
How do I run Java code online?
Type or paste your code in the editor and click Run, or press Ctrl+Enter. The code is compiled first. If it compiles, it runs and the output appears in the Output panel. If not, the compiler errors are shown with line numbers.
Which Java version does it use?
The page shows the version in the settings bar. Code written for that version, including generics, lambdas and streams, works. Newer language features such as var, records, text blocks or switch expressions need a newer version than the one shown.
Do I need to install the JDK?
No. The compiler and the Java virtual machine run inside your browser using WebAssembly. Nothing has to be installed, and you do not need an account.
Why is the first run slow?
The first time, your browser downloads the Java runtime and the compiler. These files are kept by your browser, so later runs and visits start much faster. Each run still takes a few seconds because the code is compiled and then started.
Does my class have to be called Main?
No. The tool looks for the public class in your code and uses its name for the file. Without a public class, it uses the class that has a main method. You can put several classes in the editor, but only one of them may be public.
Can I use Scanner and System.in?
Yes. Write your answers in the Input box under the editor, one line for each value your program reads. Scanner, BufferedReader and System.in.read all read from that box. The answers are not echoed in the output.
Why do I get a compiler error about a public class?
A public class must be saved in a file with the same name. The tool names the file after your public class, so the error appears only when you have more than one public class. Remove public from all but one.
Can I use packages and libraries?
A package statement works. The standard library is included, with collections, streams, java.time, threads and java.util.concurrent. External libraries such as Maven or Gradle dependencies are not available.
Do Swing, JavaFX or AWT windows work?
No. This compiler shows text output only. Programs that open a window are not shown. Console programs, algorithms and data structures work normally.
What happens if my program never ends?
You can press Stop at any time, and the run is stopped automatically when the time limit is reached. The default limit is 30 seconds and you can change it. The Java runtime restarts by reloading the page, so the next run takes longer.
Can I save or share my code?
Your code is saved in this browser automatically. You can also copy it, download it as a .java file, or use Share link to copy a link that opens the same code.
Does it work on a phone or tablet?
Yes, on a recent device with enough memory. On small screens the editor and the output are stacked one above the other. The first run needs an internet connection and a larger download than the other tools.
Is my code uploaded to a server?
No. Your code is compiled and run on your device. Only the Java runtime files are downloaded, from the CheerpJ content network, and the compiler from this site. A shared link stores the code after the # sign, which browsers do not send to a server.
More free tools from KickSolve
Related everyday tools.