INSTALLING JAVA: A STEP TO STEP GUIDE |
Steps: Here we will be proposing steps for three different operating systems as listed:
- Windows operating system
- Linux operating system
- macOS operating system
A. Windows Installation:
Steps for setting the environment in Windows operating system are as follows:
Step 1: Download the Java SE Development Kit (JDK) from the Oracle website.
Step 2: Run the JDK installer by double-clicking on it.
Step 3: Follow the on-screen instructions to install the JDK.
Go to Control Panel -> System and Security -> System. Under the Advanced System Setting option click on Environment Variables as highlighted below.
Step 4: Now, you have to alter the “Path” variable under System variables
so that it also contains the path to the Java environment. Select the
“Path” variable and click on the Edit button as highlighted
below.
Step 5: You will see a list of different paths, click on the New button, and then add the path where java is installed. By default, java is installed in “C:\Program Files\Java\jdk\bin” folder OR “C:\Program Files(x86)\Java\jdk\bin”. In case, you have installed java at any other location, then add that path.
Step 6: Click on OK, Save the settings, and you are done !! Now to check whether the installation is done correctly, open the command prompt and type javac -version. You will see that java is running on your machine.
Note: To make sure whether the compiler is set up, type javac in the command prompt (cmd.exe). You will see a list related to javac.B. Linux Installation:
In Linux, there are several ways to install java. But we will refer to the simplest and easy way to install java using a terminal. For Linux, we will install OpenJDK. OpenJDK is a free and open-source implementation of the Java programming language. Steps for setting the environment in the Linux operating system are as follows:
Step 1: Download the Java SE Development Kit (JDK) from the Oracle website.
Step 2: Extract the JDK package using the following command: tar xzvf jdk-8u212-linux-x64.tar.gz
Step 3: Change the directory to the extracted JDK directory using the following command: cd jdk1.8.0_212
Step 4: Set the JAVA_HOME environment variable to the path of the JDK directory: export JAVA_HOME=$HOME/jdk1.8.0_212
Step 5: Add the bin directory of the JDK to your PATH environment variable: export PATH=$PATH:$JAVA_HOME/bin
Step 6: Verify the installation by opening the Terminal and typing “java -version”.
Note: We are done setting up the environment in Java for Linux OS.
C. MacOS Operating System
Step 1: Download the Java SE Development Kit (JDK) from the Oracle website.
Step 2: Install the JDK by double-clicking on the downloaded DMG file.
Step 3: Set the JAVA_HOME environment variable to the path of the JDK directory: export JAVA_HOME=$(/usr/libexec/java_home)
Step 4: Add the bin directory of the JDK to your PATH environment variable: export PATH=$PATH:$JAVA_HOME/bin
Step 5: Verify the installation by opening the Terminal and typing “java -version”.