How to Run Java in Visual Studio Code on Mac OS

Java programming is very fun and interesting. The only thing you might get difficulty in is the installation part for running Java programs. So in this article let’s find out how you can run Java in visual studio code on Mac OS.

Video Tutorial: How to Run Java in Visual Studio Code on Mac OS


If you’re finding it hard to run Java in Visual Studio Code on Mac OS then you can refer to the below video for a complete guide.



Step 1: Download the latest version of JDK (Java Development Kit)


1) First things first you’ll need to download a jdk.exe and to download that you’ll have to click on the download link we’ve provided below. From there you’ll be redirected to the official JDK download page. Once you’re on that page click on the “JDK Download” button.

JDK Download Link:



2) After that, you’ll be redirected to the “Java SE Development Kit Downloads” page. Now scroll down and there you’ll see a “macOS Installer” row and next to that a download link is given. Click on that link to download the installer for Mac OS.



3) A popup screen will appear here, check the license agreement box and click on the long green download button. Depending on your internet connection the JDK file will get downloaded accordingly.



4) Now go to the folder where the downloaded “.dmg” file is available, double click on it to start the extraction process of the downloaded archive.



5) A new window will open with a “.pkg” file in it, double click on that file to start the Java setup wizard.



6) Now, a welcome window for JDK Installer will appear, there simply click on the continue button.



7) In the installation window click on the install button, if asked enter the password of your Mac machine and JDK installation will begin.

Keep at least 322Mb of free disk space available for Jdk Installation



8) After successful installation of JDK, click on the close button.



Step 2: Verify Java Version


1) To check if JDK is installed properly or not, open up your terminal by pressing “cmd+space”, type “terminal” in the search bar and press enter.



2) In the terminal type,

java –-version

and press return to check the installed version of JDK.



3) After that type

javac –-version

 and press return to check the installed version of the java compiler.



Step 3: Install Java Extension Pack in Visual Studio Code


1) Click on the extensions button and in the search bar type “Java Extension Pack” provided by Microsoft and click on the small green install button.



2) Create a New File in visual studio code by pressing “Cmd+N“.



3) Now save the newly created file by the name “”.

The key thing to note here is that you should always name your Java program the same as that of the main class and always add a “.java” extension.



4) Paste the below-provided code snippet and press the small play button to compile and execute your Java program.


class subscribe{  

public static void main(String args[]){  

     System.out.println(“Subscribe Now!”);  





5) If you see output like the below image then congrats you’ve successfully executed the Java program in Mac OS using visual studio code.


Also Read: How to run HTML code in Visual Studio Code on Mac OS


I'm a coding geek interested in cyberspace who loves to write and read

Leave a Reply

Your email address will not be published. Required fields are marked *