How to download and install Java
Java Development Kit(JDK) allows us to code and run program in Java language. Below are steps to install Java in Windows:
Step 1. Go to this link – http://www.oracle.com/technetwork/java/javase/downloads/index.html and click on JDK Download JDK button.
Step 2. Click on Accept License Agreement radio button and select JDK download link for Windows.
Step 3. Once you click on this link you will see this popup and click on Save File button.
Step 4. Once the download is done, run the exe for installing JDK. Click on Next Button.
Step 5. Once all installation is done click on next button.
Note: After installation it will generate Java folder in our specified folder or program files.
How to set Environment Variables in Java
The PATH variable gives the location of executable like javac, java etc. It is possible to run a program without specifying the PATH but you will need to give full path of executable like C:\Program Files\Java\jdk1.8.0_131\bin\javac A.java instead of simple javac A.java
The CLASSPATH variable gives location of the Library Files.
Let’s look into the steps to set the PATH and CLASSPATH
Step 1. Right Click on the My Computer and Select the properties option.
Step 2: Now select the “Advanced system settings” and select “Environment Variable” in System Properties.
Step 3: Click on New button in User variable for Admin section.
Step 4: Set the name as PATH in variable name.
Step 5: Copy the Java bin folder path from local system where JDK is installed.
Step 6: Paste the above copied path here and click on OK button.
Note: In case you already have a PATH variable in your PC, just edit the PATH variable to
PATH = %PATH%;\bin;
Step 7: We can check whether Java is installed or not using javac command. We can go to the command prompt and type javac commands.