Tutorial: Java and Visual Studio Code
Tags: tutorial, java, vscode, beginners
Published: 2021-10-30 20:02:39

---
title: Tutorial: Java and Visual Studio Code
published: true
description: Tutorial: Visual Studio Code and Java
tags: tutorial, java, vscode, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kslomyafg5grqi6lwtr6.jpg
---

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

[Visual Studio Code](https://code.visualstudio.com/)  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](https://adoptium.net/).
1. Double-click the file.
1. Accept all defaults during the installation process.

### Step 2: Install Visual Studio Code

1. Download the [Visual Studio Code](https://code.visualstudio.com/Download) installation program for your operating system.
1. Double-click the file.
1. Accept all defaults during the installation process.

### Step 3: Creating a Java Project

1. Start Visual Studio Code:

    ![vs1.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjidrcackbwcbz1ud6y1.jpeg)

1. Click the extensions icon, circled in red:

    ![vs2.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8wgfhshm5immi44ajs8.jpeg)

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

    ![vs3.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovttrrn5rn25lxl32akl.jpeg)

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

    ![vs4.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cn5lt8fevhzr4ya8kuy3.jpeg)

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

    ![vs6.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dtiryej17y9po6uzhwg.jpeg)

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

    ![vs6.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2yyrxxjb0c7lekt74o9.jpeg)

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

    ![vs7.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgeofa2r6k8bvq7t048p.jpeg)

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

    ![vs8.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pw5ojlyig4mlm99z2rn.jpeg)

1. 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 *App.java* to show the program in the editor window. App.java is a sample program that Visual Studio Code provides when you create a new Java project:

    ![vs9.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hg64hog09hm0bn5xdh5.jpeg)

1. 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:

    ![vs10.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6woh1g2ucuczv8gzbkpy.jpeg)

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

    ![vs11.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yg0qlqsmkznj2r8ewdvz.jpeg)

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

    ![v12.PNG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phhpnk2lx2ypenp27suc.jpeg)

🏆 **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`](https://twitter.com/realEdwinTorres) for more programming tips and help.*