Visual Studio Code(VS Code) is one of the most popular code editors from Microsoft. Almost everything works like charm in the VS Code save a few. Java falls in that category where you need some tweaking to run in VS Code. The VS Code Java extension fails to provide any relief as installing Java extension from VS Code will not always work. Rest assured, there are ways to turn things around.
First and foremost, you need to download and install the VS Code(if you haven’t downloaded yet). Afterward, you need to install Red Hat Open JDK by downloading it from https://developers.redhat.com/products/openjdk/download
Scroll down and click on the Download button alongside jdk-8u242-x64 MSI.
Double click on the downloaded .msi file to start the installation of Open JDK. The underlying images show the sequence of installation.
Now install Visual Studio Code Java Pack by visiting the link: https://code.visualstudio.com/docs/languages/java
Click on the ‘Download Visual Studio Code Java Pack Installer button. Once you are done with downloading, double click on the VSCodeJavaInstaller-online-win-0.2.2.exe file to start the installation. The images below show the sequence of installation.
Now launch the VS Code and click on ‘Open folder’ as shown in the image below:
Now open ‘HelloWorld.java’ file with basic code to display “Hello World!”.
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Run the Java file by pressing F5.
The output in the terminal suggest the successful running of Java code. I hope it helps.
Happy Coding!!!