How to Set Up VS Code for Java Programming

VS Code is one of the best and most advanced texts and source-code editors in the market which is available for all three major platforms or operating systems, Windows, macOS and Linux. VS …

4 mins
How to Set Up VS Code for Java Programming

VS Code is one of the best and most advanced texts and source-code editors in the market which is available for all three major platforms or operating systems, Windows, macOS and Linux. VS Code is developed actively by Microsoft and it is a free-to-use software. It supports almost all programming languages with the help of some lightweight plugins developed by Microsoft or some other experienced developers. It basically aims to replace different source code editors and IDEs for different languages and provides a unified place to code with all languages at a time.

Java is a high-level language that is both interpreted and compiled with the help of its own Java Development Kit (JDK). So, we need some tools to get started with Java in our VS Code, but before that let us have a quick look at why and when we should use VS Code and when not and what features in VS Code can boost our efficiency.

VS Code provides essential language features such as code completion, refactoring, linting, formatting, and code snippets along with convenient debugging and unit test support, it also integrates with tooling and frameworks such as Maven, Tomcat, Jetty, and Spring Boot. It's a great choice for those who work with different languages and environments very often, as you are using a single platform to edit all environments, you need to remember the shortcuts and key bindings of VS Code only and it works on all environments, similarly:

  • VS Code is fast, lightweight, free, and open source.
  • Supports many other languages, not just Java.
  • Embedded Git support.
  • Various supporting extensions are available to make your IDE really handy and easy to work upon.
  • Helps start your Java journey without installing and learning a complex IDE. Later you can shift to other complex IDEs.
  • Provides great microservices support including popular frameworks, container tooling, and cloud integration.
  • Has team-based collaboration features such as Visual Studio Live Share.
  • Boosts your productivity through IntelliSense and other code-aware editing features.

Now, let us see how you can set up VS Code for Java programming, the steps shown below are quite similar in Windows, Linux and macOS, whenever something is different for any platform it will be mentioned there only.

Set Up VS Code for Java Programming

Java requires its Java Development Kit to interpret and compile the .java files to byte codes and later into machine-readable codes. Hence the first step would be to download and install the latest version (or any specific version according to your requirement) of Java Development Kit (JDK) from any of the following sources:

Step 1: Download and Install JDK

As mentioned above, you should download the JDK from one of the recommended sources and then it is fairly simple to install the JDK as you need not tweak any settings, just go next and next to install the JDK in Windows and follow similar instructions in Linux and macOS.


Download the JDK package according to your operating system and requirements, as shown above.

Step 2: Download and Install VS Code

Download VS Code

Download VS Code from the official site and install it by checking the fields as shown below in the image. Checking the shown fields can get you saved from various errors and complexities later on and also shows VS Code on right-click in Windows that keeps VS Code a click away (isn't that nice?).

VS Code Installation

If you have VS Code already installed on your device, you can simply skip to the next step where we will install the Java Extension Pack for VS Code.

Step 3: Install Java Extension Pack in VS Code

Java Extension pack for VS Code

As shown above, after installing the VS Code, open it and browse to the Plugins section and search for "Java Extension Pack" and download the plugin package shown at the top created by Microsoft. It is a collection of a total of 6 plugins that make Java programming easy and efficient in VS Code. That was all for setting up VS Code for Java programming. 

Step 4: Open a folder and start coding


You can now open a folder in VS Code and start coding in Java. Here is a simple code for Hello World in Java:

public class hello {
    public static void main(String[] args) {
        System.out.println("Hello World");

It will simply print a "Hello World" text in the terminal as output. Also, you can install the Code Runner extension by Jun Han from the plugins section to run your codes in the terminal with a single click.

Bonus Tip: Enable the ‘AutoSave’ option in the Files menu. It really helps, many times when you are working on some sort of program you might face irritating errors because you had forgotten to save the code.

If you are new to Java, then there are tons of intuitive resources available on the internet which can help you learn basic Java programming from scratch. A few of them are CodewithHarry’s Java Playlist on YouTube and Tutorialspoint Java Guide. Also, a great resource and companion is the Java documentation by Oracle.

Hope the guide helps. Feel free to put your suggestions, queries and comments below.

Was this Article Helpful?
Ajay Choudhury

Ajay Choudhury

A learner and a student of technlogy. He loves sharing experiences and learning with others through his projects and blog. Along with technology, he loves playing football and enjoys listening to music and podcasts.



OrbitGadget — A constructive and and resourceful hub for computer science geeks. Let us achieve together.

Privacy Policy Disclosure Site Terms Atom Feed Sitemap

Made with ❤️ and Django. OrbitGadget © 2020 - 2022.