Java and Java’s Virtual Machine (JVM) has been widely used for many software needs. Java is a platform that can run applications (Java based) on a particular operating system by interpreting a number of bytecodes. Not only required by a developer or programmer, Java is also required for ordinary users to run various Java-based applications contained on the computer, by utilizing Java Runtime.
There are different ways to install Java on multiple platforms. Unlike Windows, how to install Java on Ubuntu is usually done through the terminal. Before installing Java, it’s a good idea to check if your Ubuntu is already installed Java or not. If you have, at least you can find out which version is installed on your Ubuntu. If possible you would like to reinstall for the latest version of Java. There are two ways to install java on Ubuntu Linux, ie installation by default and specific installations.
# 1 How To Install Java By Default
For how to install by default, you can follow the steps below.
1. Open a terminal on your Ubuntu. Update to update your Ubuntu to be up-to-date, with the command:
sudo apt-get update
2. Then, do the following command to install JDK:
sudo apt-get install default-jdk
Type Y to continue if there is a question as indicated by the arrow in the image below.
and the commands below to install JRE.
sudo apt-get install default-jre
You need to know, if you have installed JDK command, then you no longer need to run the command to install JRE. Because, in JDK already have JRE.
JDK (Java Development Kit) is a Java install package that is usually required by programmers by utilizing the compiler contained in it to run the bytecode of the program. In JDK there is also Java Runtime to run the application. Unlike the JRE (Java Runtime Environment) that can only be used to run Java-based applications. JRE there is no compiler that can run bytecode when you write a program.
# 2 How to Install Java Specifically
There are two ways to install Java specifically, by using the openjdk and oracle commands. This specific installation aims to install the desired Java version as needed. For example, an Ubuntu user requires Java 7 to be installed on the system, then the user can directly use the openjdk-7- command.
Similarly, if you want to mengintall oracle Java 8, the command used is specific. The steps of installing the above two ways are not much different. There are only differences in the command.
The following steps to install Java openjdk.
Actually, openjdk and default Java types are the same. Openjdk is the default Java type that is used to install Java specifically as per the user’s wish.
1. Type the update command on the terminal to make sure your Ubuntu is up-to-date.
sudo apt-get update
2. Then type the command for the Java installation. For example, you want to install Java 8. Then the command looks like this:
sudo apt-get install openjdk-8-jdk
or if you want to install Java SE Runtime Environment:
sudo apt-get install openjdk-8-jre
If you want to install a different version of Java, you just replace the number 8 on the command in accordance with the version number you want.
3. Wait until the installation process is complete.
Steps to install Java oracle.
1. Before installing the Java oracle, you must add the Oracle PPA to your repository. Type the command below:
sudo add-apt-repository ppa: webupd8team / java
2. After that, update with command:
sudo apt-get update
3. Next, you can type the installation command for the Java version you want. Just like openjdk, you just need to replace the Java version of the oracle version of the following command with the version number you want. Here I am installing Java oracle 8.
sudo apt-get install oracle-java8-installer
4. Wait for the installation to complete. If there is a configuration request like the image below, select OK by pressing Enter.
5. Navigate to the Yes option, then press Enter on the keyboard.
6. Wait for the installation to complete.
How to install Java on Ubuntu. You can check your install results by typing the command:
From the results of the command you will know which java version is installed on your Ubuntu. Java version usually begins with the number 1. then proceed with the version (in numbers) Java successfully installed. If you have other questions or comments about some how to install java in Linux above, please input in the comment field below. thanks.