How to Set Up Java Development in Visual Studio Code on Windows | vsCode Java Development Basics

July 27, 2019 posted by



hey guys in this video I'm going to show you how you can set up your visual studio code editor for the Java development so obviously the first step is to download the visual studio code and if you don't know how to download Visual Studio code you can just search for Visual Studio code on your favorite search engine and then the first link which will appear here will be from code dot visual studio dot on this link and directly you will see this green button here or on the top so currently I'm just making this video for Windows or but this same method will work for Mac OS or any other Linux operating system so you can see this option just click on this button and then an executable file will be downloaded which you can execute and it's very simple to install Visual Studio code so I'm not going to show you how you can install Visual Studio code now after installing Visual Studio code the most important thing you need to develop your Java code or projects with Visual Studio code is the Java JDK so if you don't have Java JDK installed you can search for Java JDK and then you will see few links here so you can see in my case I can see Java SE development kit 8 which was the older JDK version and when I scroll down I can see Java SE development kit 12 which is the latest version at the time of making this video make sure that this link is from Oracle comm right so I'm going to just click on this link which says Java S II a development kit 12 or whatever version is the latest version when you are installing the Java development kit okay so you will see this kind of page and then just accept the license terms and conditions and then choose the executable file or the binary file for your operating system so as this video is made on Windows operating system so I can just click on this option which says Windows – x64 underscore bin dot exe extension right so just download this executable file and then install it and the steps are really simple so once again you just need to click on this executable file and then just follow the procedure and click on some next buttons and you will be good to go the most important thing is to set the Java home environment variable so I have already created a video on how to install Java development kit and how you can set your environment variable that is Java home environment variable so I will put the link of that video in the description of this video so you can just see that video and install java jdk and set java home environment variable so once you have installed Visual Studio code and you have installed Java development kit and set the environment variable the last thing which remains is you just need to search for Visual Studio code Java and you will see this link all the links which I'm showing you I'm going to put all the links in the description of this video so you can directly click those link and just go to those websites so you just need to click on this link which says Java in Visual Studio code or code dot Visual Studio com forward slash dogs forward slash languages forward slash Java so I'm going to just click on this link and here you can read this document and see the procedure on how Java is supported in Visual Studio code the most important thing I want to show you here is this option which is download Visual Studio code Java pack installer so in order to fast-track your Java development in Visual Studio code Microsoft has already created this Java pack installer for Visual Studio code so you can directly download this and install this and it will be automatically added to your Visual Studio code so it will make the development of Java projects on your Visual Studio code easier so I'm going to just click on this button which says download Visual Studio code Java pack installer and then save this file now once this executable file is downloaded for Visual Studio code Java pack installer I'm going to click on this link and then I'm going to minimize the browser and you can see this window has been started for Visual Studio code Java pack installer first is to accept license terms and conditions so I'm going to click Next the second step is to configure the components for Java development kit and Visual Studio code and as you can see if Java development kit and Visual Studio code is installed on your operating system then you will be able to see this kind of message in front of Java development kit you can see it's installed on my system and Visual Studio code is installed on my system that's why I told you to install these two things first before installing this Java pack installer for Visual Studio code so just click on install and then wait for some time so you don't need to do anything this installer will find everything and set everything automatically for you for Visual Studio code and after a few seconds you will see this message which says completing the setup wizard and launch Visual Studio code so I'm going to just click on the finish button which is going to launch the visual studio code with this package installed and now Visual Studio code is opened right so once the Visual Studio code is opened you can develop your Java project in your Visual Studio code so let's develop a simple java code in Visual Studio code editor so let's say I want to create this project in this path on my PC under this Java with Visual Studio code directory or folder so you can open this folder in Visual Studio code by just clicking on file and then just click on open folder and then just copy this path and paste it here and then just click on select folder which is going to open this folder in Visual Studio code so you can see this folder is open inside Visual Studio code which is Java with vs code or what you can do is you can just copy this path once again and right-click on your windows icon on the left hand side and then open the command prompt from here so I'm going to just click on command prompt which is going to open the command prompt and once the command prompt is open you can just write CD and then paste this path which you have copied and then press ENTER and from here also you can just write a code and then space dot okay code space dot and what this is going to do is this is going to open your Visual Studio code inside this directory so this directory you need to CD into this directory using the command prompt and then they give this command then also it's going to open this folder inside Visual Studio code so let's see this how it works so I'm going to close the Visual Studio code and then give this command and you will see this is also going to open this folder inside the Visual Studio code editor so once this folder is open in your Visual Studio code editor you can create a dot Java file by just clicking on this icon with his new file and let's create a new file let's say hello dot Java and then press Enter which is going to create this hello dot Java and also give you this tab which is going to show you some of the documentation about Java development in the Visual Studio code so I'm going to just close this and this welcome window for now and just leave the hello dot Java file opened now what you can do here is you can create a class let's say so let's create a class so I'm going to just say class and you can see this intellisense and you will see two options so just click on the second option here which is automatically going to create a sample class for you which is public class hello and here when you want to create a mean method year so you can just type mean and then click on this intellisense which comes here or press enter then it's going to create your public static void main method and inside this main method you can for example print anything so I'm going to just write system dot out dot print line and here let's print something so I'm going to just say print test and when you want to run this program you can see this option directly visible here so you can just click on this Run button or link here which is going to run in your code first it's going to compile your code and if it compiles successfully then it's going to run your code let's say we just intentionally put some error here and then try to compile directly you can see this red squiggly line which is going to warn you that is some problem in your code and let's say I'm going to run this code again and it's going to build your code and it's going to show the error compilation error because we missed the semicolon after this line of code so you can see these warnings or compilation problems if you have any in your terminal here in the debug console you can also debug your code by this option so let's say I'm going to create a string variable I'm going to just say string here and then declare at this variable let's say string x equals test so test and then I'm going to pass this X variable here inside the print line method and let's say I want to debug on the line number eight so you can see this red dot here you can move this red dot anywhere so I'm going to just click on this red dot and then once this red dot is visible I can just click on this debug option which is going to run your code in debug mode and on the left hand side you can see the variable value also so you can see the variable value and also all the debugging variables you will be able to see on the left-hand side and if you want to go further for example if you want to step over or step into or step out you can use these top options so let's say I want to step over so I can click on this button or if I want to just stop the debugging then I can click on the red button which is going to stop this debugging now this is how you can create your Java project and run and debug your Java project in your Visual Studio code editor now if you want some more support of Java side visual studio code you can always go to this icon which says extensions and search for a Java extension so just search for Java here and you will see plenty of options available related to Java so for example if you want to develop a maven project for Java then this extension might be useful and you can see on my visual studio code it's already installed I haven't installed it specifically but its installed automatically because I have already installed this option which is download Visual Studio Java pack installer so some of the extensions are automatically installed when you install this Java package extension for Visual Studio code so you can just see these extension for example Java debugger if you want there are 300,000 download for this extension so you can try this extension or Tomcat for Java extensions so you can see plenty of extensions available for you for your help so you can try these extensions also but basic applications related to Java you can directly start creating with this extension which we have downloaded which is the Java pack extension without any problem it's going to work so this is how you can develop your Java project inside so this is how you can develop your Java projects inside Visual Studio code I hope you've enjoyed this video and I will see you in you

9 Comments

9 Replies to “How to Set Up Java Development in Visual Studio Code on Windows | vsCode Java Development Basics”

  1. shrey gupta says:

    AMAZING VIDEO SIR KEEP GOING !!

  2. Diana Omollo says:

    Hey, could you please make a video on how to convert text (formatted with a line and bullet list) in rich text box to HTML. Thanks

  3. anshul khanna says:

    Sir which IDE is used by companies for JAVA

  4. Arivazhagan S says:

    Does this work on 32bit?

  5. Global Entertainers says:

    Thank you brother.

  6. ESMusic Quirky says:

    Windows sucks dude

  7. Manraj Singh says:

    first

  8. victor jo says:

    Nice video! 👍🏽 Please what open-source Java projects would you recommend for beginners to contribute to?

  9. Nithin cr says:

    Thanks

Leave a Comment

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