< Prev
Next >



How to set environment variables for Java




Let's see how to set up environment variables in a Windows Operating System in order to execute your first Java program.

  1. Open the folder where the Java Development Kit(JDK) is installed in your system.
  2. Next, open the bin folder in the JDK folder and copy the path to this folder.


  3. In our case, we have installed JDK in its default directory -
    "C:\Program Files\Java\jdk1.8.0_144"

    Hence, the path of the bin folder in JDK in our system is -
    C:\Program Files\Java\jdk1.8.0_144\bin





  4. Next, in the search box of the Windows Operating System(Windows 7 to Windows 10), type in windows command sysdm.cpl and press the Enter button to open the System Properties window.



  5. Figure 1





  6. Once the window of System properties opens up, we need to click on its tab that says, Advanced.



  7. Figure 2





  8. In the Advanced tab window, we need to click on the button that says, Environment Variables , in order to set the environment variables for executing Java programs.



  9. Figure 3





  10. In the next window of Environment Variables, we first need to click on Path variable in the section of System variables and then click on Edit button, to edit the value of this Path System variable.



  11. Figure 4



  12. Clicking the Edit button to edit the value of Path System variable, opens a new dialog window of Edit System Variable. This window has two options - Variable name and Variable value.


  13. Figure 6





  14. Next, click the OK button on the previous window of Environment Variables, to save and apply the changes.


  15. Figure 5





  16. Next, in the search box of the Windows Operating System(Windows 7 to Windows 10), type in the windows command cmd and press Enter to open the Command Prompt window.



  17. Figure 6
    .




  18. In the Command Prompt window, we will check whether Java is successfully installed and running in our system. To do this, we just need to type a command javac(which calls the Java Compiler) and press Enter. VoilĂ ! Java Compiler responds and shows us a set of options that we could use with the javac command.



  19. Figure 7

    This concludes the successful setup of the environment variables of Java, to run the Java programs. Next in, executing our first Java program.




    Please share this article -





    < Prev
    Next >
    < Install JDK
    First Java Program >
Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
Python

Ad2