< Prev
Next >

How to set the environment variables for Java

Let us see how to set up the 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 a Windows command sysdm.cpl and press the Enter button, which opens 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, to set the environment variables for executing the 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 the Edit button, to edit the value of this Path System variable.

  11. Figure 4

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

    • Against the box of Variable value, we need to paste the path to the bin folder of JDK(please, don't forget to add a semicolon at the end of this path.)
    • Next, click the OK button to save the new value of the Path System variable.

    Figure 6

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

  14. Figure 5

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

  16. Figure 6

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

  18. Figure 7

    This concludes a successful setup of the Java environment variables, 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

Please subscribe to our social media channels for daily updates.

Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page



Please check our latest addition