Environment variable : Concept
- When any program runs on computer, it don’t know where required software are installed.
- Suppose there are 2 computers having Java installed. Let say PC1 has Java installed at C:\Program Files\Java and PC2 has D:\Java. Now question is how code will understand where Java is installed. As a solution to this issue, Java says set a system level variable named JAVA_HOME with value as Path where Java is installed. Then code can access JAVA_HOME to get installation path of Java.
On the same line, for other installations similar variables can be added at system level. All such variables are called as Environment Variables.
Environment variables are dynamic as their value can be changed when required.
Environment variable for Java
Windows 10 and Windows 8

- Go to System (Control Panel)
- Click the Advanced system settings.
- Click Environment Variables.
- Click on New.
- Set variable name as JAVA_HOME.
- Set variable value as path to java installation.
- Click ok to save.
- In same section check for PATH variable.
If present select it and click on Edit. To append JAVA_HOME to existing PATH variable value, type semicolon (;) and then type %JAVA_HOME%\bin. Do not delete already existing data in variable value section.
If not present create new environment variable with name as PATH and value as %JAVA_HOME%\bin.
Windows 7
- From the desktop, right click the Computer icon.
- Choose Properties from the context menu.
- Click the Advanced system settings link.
- Then follow procedure as specified earlier.
No comments:
Post a Comment