KickSolve • Free • Private

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.

Real javac compilerScanner / System.in inputCollections, streams, threadsNothing uploaded
Settings
Java8
Layout
Text
14
Input for Scanner / System.in

Scanner, BufferedReader and System.in read from this box. The answers are not echoed in the output.

OutputReady

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.

Write or paste your codeType Java in the editor, paste your own code, or pick a ready-made example from the list.
Press RunClick Run or press Ctrl+Enter. The code is compiled with javac and then run. The first run loads Java once, then the output appears next to your code.
Fix, share and saveClick a red line number to jump to a compiler error. Copy the code, download it as a .java file or share a link.

Why choose KickSolve

The real compiler, clear errors and a private editor.

Real javacYour code is compiled by the actual Java compiler, so you get the same errors and warnings as on your computer.
A real editorLine numbers, syntax colours, auto-indent, bracket pairing and comment shortcuts.
Clickable errorsCompiler errors and exception stack traces show a line number. Click it to jump to that line.
Private by designYour code is compiled and run on your device and is never uploaded. A shared link keeps it after the # sign.

What you can do with this Java compiler

Everything the editor and output panel offer.

Learn JavaTry variables, loops, methods, classes and interfaces with ready-made examples.
Test a snippetCheck a piece of code from a tutorial or a question without setting up a project.
Practise Scanner inputRun programs that read from System.in by typing the values in the Input box.
Solve coding exercisesWork through algorithms, data structures and interview questions.
Use collections and streamsRun lists, maps, sets, lambdas and the Stream API.
Try concurrencyRun threads, executors and futures with java.util.concurrent.
Study exceptionsSee compiler errors and stack traces with the line numbers that caused them.
Teach and shareShare a link to a snippet so someone else can run the same code.

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.

FeatureWorks?Notes
Classes, interfaces, enums, inner and anonymous classesYesSeveral classes in one editor, only one public
Generics, lambdas, method references, StreamsYesPart of Java 8
Collections, String, StringBuilder, Math, java.timeYesStandard library is included
Scanner, BufferedReader, System.inYesReads from the Input box
Threads, ExecutorService, CompletableFutureYesIncluded
Exceptions and stack tracesYesClick the line number to jump to your code
package statementYesThe class is started with its package name
var, records, text blocks, switch expressionsDependsOnly on a newer Java version than 8
File I/OTemporaryFiles live in a temporary store in your browser
Swing, AWT, JavaFX windowsNoText output only
Sockets, Maven or Gradle dependenciesNoStandard library only

Online Java compiler vs JDK on your computer vs hosted services

When each is the better choice.

This compilerJDK on your computerHosted online compilers
SetupNone, works in the browserInstall the JDK and an editorNone
Where code runsOn your deviceOn your deviceOn a remote server
Startup timeA few seconds per run, large first downloadFastestFast, but depends on the server
Java versionFixed by the pageAny you installOften several
LibrariesStandard libraryAnything you addStandard library, some more
Best forLearning, quick tests and private snippetsReal projectsTrying 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.