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:
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:
- Open command prompt as an administrator
- Copy the path of bin directory of JDK
- Now write “set path = copied_path”
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:
- Go to properties of my computer
- Click on advance system settings tab
- Now click on environmental variables.
- Now double click on “new…”
- In variable name write ‘path’
- now copy the path of bin folder of JDK
- Paste that path in variable value
- Click on “OK” button to save the settings
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:
Through this statement JDK will be installed in home directory under root.
Hope you like this article. Thanks for reading…