we will learn about how to install JDK and JRE in Ubuntu. But lets have a look on definition of jdk and jre. JRE is Java Run time Environment. It is used to provide Run time environment. It physically exists and contains set of libraries + other files that JVM uses at Run time . JDK stands for Java Development Kit. It physically exist and it contains JRE + development tools.
Now lets have a look on how to install jdk and jre in Ubuntu
Step-1 Open the terminal window by CTRL+ALT+T. Install the default JDK by the following command
sudo apt-get install default-jdk
and press enter.
Wait for the file to completely install, when it shows done then move to the next step.
Step-2 Now install the default JRE file using terminal window by the following command
sudo apt-get install default-jre
and wait for the file to install.
Step-3 Now to download jdk Click Here
Step-4 Now to download jre Click Here
Step-5 After the completion of download open the terminal window and run:
It will ask for the administration permission and you have to enter your root password in it, as you’ll press enter a new window will open.
Step-6 Now open Computer->Home->Downloads->Your downloaded JDK file: “jdk-8u131-linux-x64.tar.gz”->right click on this file->Open this file with Archive Manager->Extract the file in Computers /usr/ java
Repeat the same steps to extract JRE file.
Computer->Home->Downloads->Your downloaded JRE file: “jre-8u131-linux-x64.tar.gz”->right click on this file->Open this file with Archive Manager->Extract the file in Computers/usr/ java
Step-7 Once the file is extracted open the Terminal Window by using Ctrl+Alt+T.
Step-8 Open the terminal and run the following command :
sudo apt-get update
and press Enter, it will ask for the system password, enter the password and wait for sometime. It will update all the latest packages installed on your system.
Step-9 After the package lists reading is done, double-check your directories at this point, you should have an uncompressed binary directory in /usr//java for the Java JDK/JRE,
Type the following command to change the directory:
Type the following command to view the list of folders inside the directory:
Step-10 Once the directories are checked now it’s time to install the JDK file. Type the following command in the terminal window:
sudo gedit /etc/environment
Then it will ask you to enter your system password, as you input the password press enter.
You will see an editor will open.
Step-11 Type the following commands in the editor:
Save the file by pressing CTRL+S and close the window.
Step-12 Reload the file by typing the following command:
Step-13 Now type
sudo gedit ~/.bashrc<
and enter the following path in the editor at the bottom of the page and save the file by CTRL+S or by pressing SAVE button on the top right corner and close the editor window
Path to enter in the file:
Step-14 Now type the following command to reload the file:
Check the expected results by typing following commands:
It must display “//usr/java/jdk1.8.0_131” and “/usr/java/jre1.8.0_131” respectively.
Step-15 Now, your JDK and JRE files are now installed in your system.
Check your installation by typing-
in the terminal window.
If you get this as a result:
“java version “1.8.0_131”
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)”