DEV Community

Cover image for Tutorial: Java and Visual Studio Code
Edwin Torres
Edwin Torres

Posted on • Updated on

Tutorial: Java and Visual Studio Code

An integrated development environment (IDE) makes it easy to write code.

Visual Studio Code is an IDE that works well with a variety of programming languages, including Java ☕.

This tutorial describes how to set up Visual Studio Code and write your first Java program.

Step 1: Install Java

  1. Download the OpenJDK LTS release.
  2. Double-click the file.
  3. Accept all defaults during the installation process.

Step 2: Install Visual Studio Code

  1. Download the Visual Studio Code installation program for your operating system.
  2. Double-click the file.
  3. Accept all defaults during the installation process.

Step 3: Creating a Java Project

  1. Start Visual Studio Code:


  2. Click the extensions icon, circled in red:


  3. Enter Extension Pack for Java in the text box to find the extension pack, then click the Install button to install the extension:


  4. Click the files icon in the top-left, then click the Create Java Project button in the bottom-left:


  5. Click No build tools to create a simple Java project in Visual Studio Code:


  6. Select a folder location for your Java project. Select Desktop, then click the Select the project location button:


  7. In the text box, type a project name, for example: myjavaproject. Then press the Enter key.


  8. If prompted to trust the authors, click the checkbox to trust the authors, then click the Yes button to trust the authors:


  9. If the Java Help Center window appears, click the x button to dismiss it. Then in the left window pane, expand MYJAVAPROJECT > src and click to show the program in the editor window. is a sample program that Visual Studio Code provides when you create a new Java project:


  10. Wait a few seconds, then you will see Run and Debug links above the main() method declaration in the editor window. Click the Run button to run the Java program:


  11. Note the output of the program in the terminal window below the editor window:


  12. To create a new Java program in the project, right-click the src folder and click New File. Type a program filename, e.g., and press the Enter key. Now edit your new Java program in the editor window.


🏆 Congratulations!

You are now ready to develop Java programs using Visual Studio Code. This IDE has advanced features such as inline documentation, auto-complete, syntax checking, a debugger, and more. Java program development will be much easier now!

Thanks for reading. 😃

Follow me on Twitter @realEdwinTorres for more programming tips and help.

Top comments (0)