OneCompiler
Java

Java

Backend

Java is one of the most widely used languages for backend services, Android apps and large systems. This workspace gives you a ready Java setup with the JDK installed, so you can write a class and run it from the terminal without configuring anything.

What's included

Compile and run from the terminal

The JDK is installed and on your PATH. Run java Main.java to compile and run in one step, or use javac and java separately if you prefer.

Real VS Code

The full cloud editor with an integrated terminal, the Java extensions and a debug config that ships in the .vscode folder.

Git ready

Clone, commit and push from the terminal, or connect a GitHub repo whenever you're ready.

Fast cold start

Boots in about a minute, with the JDK already in place so there's nothing to download first.

Tech stack

JavaJDKjavacVS Code

What is Java?

Java is a general-purpose, object-oriented language that compiles to bytecode and runs on the Java Virtual Machine. That bytecode runs the same way across operating systems, which is why Java has stayed a default choice for server-side software and enterprise applications for decades. It's also the original language for native Android development.

This workspace is a plain Java starter. It ships a single Main class that prints a greeting, so you have a working program to run from the first second and can grow it into whatever you're building.

What's inside this workspace

The starter is one file, Main.java, with a standard main method that prints Hello, World!. The JDK is already installed, and the .vscode folder includes a launch configuration so you can run the Main class straight from the editor.

There's no build tool wired up by default, so this is the lightweight way to learn Java or work through exercises. If your project grows, you can add Maven or Gradle from the terminal and structure it into packages.

Building and running

Open the terminal and run java Main.java. Recent JDKs let you launch a single source file directly, so it compiles and runs in one command. You can also do it the classic way with javac Main.java to produce Main.class, then java Main to run it.

To debug, use the launch config in the .vscode folder. Set a breakpoint in Main.java and start the Main configuration to step through your code.

What you can build

Console programs, algorithm practice, data structures, command-line tools, or the starting point for a larger application once you add a build tool and dependencies. It's a clean base for learning the language or sketching out backend logic.

Frequently asked questions

How do I run my Java program?

Open the terminal and run java Main.java. That compiles and runs the file in one step. You can also compile with javac Main.java and then run java Main if you'd rather keep the two steps separate.

Is there a build tool like Maven or Gradle?

Not by default. The template is a single-file starter so you can run code immediately. If you need dependency management or a multi-module layout, install Maven or Gradle from the terminal and add the usual build file.

Can I debug Java here?

Yes. The .vscode folder ships a Java launch config. Set breakpoints in Main.java and start it from the Run and Debug panel to step through your code in the cloud editor.

Does this run a web server I can preview in the browser?

No, this template is a console program that prints to the terminal. If you want a web application with a browser preview, start from the Spring Boot template instead.

Can I add more classes and packages?

Yes. Create new .java files in the workspace and organise them into packages as your project grows. Compile them together with javac, or move to a build tool once the project gets bigger.

Is it free?

Java runs on a paid Studio plan. Templates that are free to launch are marked as such, and you can move to a paid plan from the pricing page to use this one.

Related templates

Java online Studio — cloud Java workspace | OneCompiler