Environment variables are very important part of every system which defines the path to run a program Or specify to a program which directory or folder to install files. The Environment variables are dynamic and it is because they can change. The very common term that you may have heard as environment variables are %appdata% , %local% , %temp% , %userprofile% etc.
When it comes to java programming these enviournment vriables are the priority of it and you can’t go further without defining these.
How Environment Variables are important in Java Programming:
Once you have installed java on your windows system then in order to make java program or to compile them you need to set a path using environment variables. It helps you to use the tools inside java in command prompt, without defining path you can’t go further and it will give you the error like this is not recognized as an internal or external command.
To Set path in Java or to Set environment variable in Java for windows 10 and 8 follow below steps:
Copying the Path:
- Open File Explorer.
- Go to C>>Program Files>>Java>>jdk>>bin
- Here you will see a number of files or tools, just copy the path it from the path area.
- Once you have copies the path follow the below Pasting process to set the environment variable.
Pasting the Path:
- Go to control panel using search Or using Run by pressing Windows+R key simultaneously, which will open run windows, now type Control Panel on it and Hit Ok.
- Once you are on the Control Panel, Click on Systems and Security.
- Under Systems and Security windows Go to System.
- Now, click on Advanced System Settings from the left side of the window.
- Under Systems Properties window click on Environment variables button.
- Now under the System Variables area, find the path variable and double click on it.
- It will take you to the Edit Environment variable window, here click on New button from the right side.
- Now paste the path you have copied, and hit Ok to every previous window to close them.
Note: Before going to C drive to copy path you must know where exactly the java is installed in your windows OS. Usually, we use C drive for that, but if your windows OS installed in other partition then look for the rest of the path there.
Once done with copying and pasting process then you can compile and run your java program. After all the above process you also can set path for other programs using the above steps, which will remains same most version of windows like windows 10, 8, 7, XP you have opened the control panel.