How To

HOW TO SET PATH OF JDK IN WINDOWS & LINUX OS

Why to set path of JDK in java?

Without setting path you cannot use tools like java, javac etc.

Saving the source file of java inside the bin directory of JDK does not require the path to be set as all the tools are available in the current directory. But if you are saving your java file outside the bin folder of JDK then you have to set path in order to use all the tools.

So accordingly there are two ways of setting the path in java:

  1. Temporary
  2. Permanent

Which path is needed to be set?

Generally the path that you need to set is found on the program files (or program files (x86)) of c drive in the folder named “java”. Now open JDK inside this folder and locate “bin” folder inside JDK, this is the path that is required to be set. This path looks something like:

C:\Program Files (x86)\Java\jdk1.8.0_45\bin

Copy that path.

Setting up the temporary path of JDK:

To set path in java temporarily what you have to do is:

  1. Open command prompt as an administrator
  2. Copy the path of bin directory of JDK
  3. Now write “set path = copied_path”

8

The problem?

The problem associated with temporary path is that every time we need to use tools to compile source code or to run the program we need to set path every single time and hence it is a bad programming practice. We need something more dynamic, so we use permanent setting of path…

ALSO READ: Top 12 Ways To Earn Money Online

Setting up the permanent path of JDK:

Few simple steps you need to follow to set up path of JDK are:

  1. Go to properties of my computer

1

  1. Click on advance system settings tab

2

  1. Now click on environmental variables.

3

  1. Now double click on new…”

4

  1. In variable name write path’

5

  1. now copy the path of bin folder of JDK

6

  1. Paste that path in variable value

7

  1. Click on “OK” button to save the settings

9

The permanent path of JDK is now set, and you can run any source code which is stored in any drive of your computer.

11


 

How to set path of JDK in linux OS:

Setting the path of JDK in Linux OS is same as that in Windows OS, the only difference is that in former case export tool is used instead of set and hence it looks something like:

export PATH=$PATH:/home/jdk1.8.0_45/bin

Through this statement JDK will be installed in home directory under root.

Hope you like this article. Thanks for reading…

Leave a Reply

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