How to set path in Java in Windows?

Setting path in java: Here, we are going to learn how to set path in java in Windows? This tutorial has step by step guide with pictures. By Preeti Jain Last updated : January 02, 2024

To set path in java in two ways:

  1. Temporary [Work Till PC Shutdown]
  2. Permanent [Work for always]

Setting Temporary Path in Java in Windows

First, we will study how to set a temporary path for compiling and execution of java program?

  1. Open the command prompt
  2. We will copy the address of the JDK/Bin directory and let us suppose our JDK Address is "C:\Program Files\Java\jdk-10.0.2\bin" then copy this address.
  3. After copying address come back to command prompt screen and type a command like this,
  4. path = C:\Program Files\Java\jdk-10.0.2\bin and press enter.

Setting Permanent Path in Java in Windows

Second, we will study how to set a temporary path for compiling and execution of java program.

1) Go to the My Computer icon and right-click on the icon and go to the properties option and click on it. Please see the below screenshot.

set path in java (1)

2) After clicking on properties option a new window will appear on the screen like this.

set path in java (2)

3) After clicking on properties option then go to the advanced system settings tab and then click on it then a new window will appear on the screen[System Properties].

set path in java (3)

4) After clicking on advanced system settings tab a new window will appear on the screen [System Properties] and then go to the Environment Variables and then click on it.

set path in java (4)

5) After clicking on Environment Variables button then a new window will appear on the screen [Environment Variables] then go to the path of user variable and click on edit option and in case if path option does not exists then we can create new variable by clicking on new button of user variable.

set path in java (5)

6) After clicking on the edit button of user variables then a new window will appear on the screen [Edit Environment variable] then go to the new button and click on it and there paste the path of JDK and click on ok button.

set path in java (6)

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.