Skip to content Skip to sidebar Skip to footer

2 Ways to Install Java on Linux Ubuntu for Beginners (Complete+Pictures)

Java and Java’s Virtual Machine (JVM) have been widely used for many needs software. Java is a platform which can run applications (Java based) on a particular operating system by interpreting a number of bytecode. Not only needed by a developer or programmer, Java is also needed for ordinary users to run various Java-based applications on their computers, namely by utilizing Java Runtime.

How to Install Java on Linux Ubuntu

There are different ways to install Java in some platform. Unlike Windows, how to install Java on Ubuntu is usually done through the terminal. Before installing Java, it’s a good idea to check whether your Ubuntu has Java installed or not. If you have, at least you can find out which version is installed on your Ubuntu. If possible you want to do a reinstall for the latest version of Java. There are two ways to install java on Linux Ubuntu, namely the appropriate installation default and specific installations.

#1 How to Install Java by Default

For the proper installation method default, you can follow the steps below.

1. Open a terminal on your Ubuntu. Do updates to update your Ubuntu to up-to-date, with the command:

sudo apt-get update

how to install java on linux
2. Then, do the below command to install the 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.

how to install java on linux ubuntu
and below command to install JRE.

sudo apt-get install default-jre

install default jre
You need to know, if you have installed the command JDK, then you no longer need to run the command to install JRE. Because, in the JDK there is already a JRE.

JDK (Java Development Kit) is a Java installation package that is usually needed by programmer by using compiler contained in it to run bytecode from the program. In the JDK there is also a Java Runtime to run applications. Unlike the JRE (Java Runtime Environment) which can only be used to run Java-based applications. JRE does not exist compiler who can run bytecode when you write a program.

#2 How to Install Java Specifically

There are two specific ways to install Java, namely by using the command openjdk and oracle. This specific installation aims to install the desired version of Java as needed. For example, an Ubuntu user needs Java 7 to be installed on their system, so that user can directly use the command openjdk-7-.

Likewise if you want to install oracle java 8, the command used is specific. The installation steps of the two methods above are not much different. There are only differences in the orders.

Following steps to install Java openjdk.

Actually, Java type openjdk and default is the same. Openjdk is java type default which is used to install Java specifically according to the user’s wishes.

1. Type the command updates on the terminal to make sure your Ubuntu up-to-date.

sudo apt-get update

sudo apt update
2. Then type the command for Java installation. For example, you want to install Java 8. Then the command is like this:

sudo apt-get install openjdk-8-jdk

install openjdk-jdk
or if you want to install the Java SE Runtime Environment:

sudo apt-get install openjdk-8-jre

how to install java on linux for beginners
If you want to install a different version of Java, you just need to replace the number 8 in the command according to the version number you want.

3. Wait for the installation process to complete.

Steps to install Java oracle.

1. Before installing Java oracle, you must add the Oracle PPA to your repository. Type the command below:

sudo add-apt-repository ppa:webupd8team/java

install ppa oracle

2. After that, do updates with the command:

sudo apt-get update

sudo apt update

3. Next, you can type the installation command for the Java version you want. Same as openjdk, You just need to replace the Java version number oracle the following command with the version number you want. Here I do the Java installation oracle 8.

sudo apt-get install oracle-java8-installer

install oracle java

4. Wait for the installation to finish. If there is a configuration request as shown below, select OK by pressing Enter.

select OK with enter

5. Navigate to the Yes option, then press Enter on keyboard.

select Yes with enter in Yes
6. Wait for the installation to complete.

That’s how to install Java on Ubuntu. You can check the results of your installation by typing the command:

java -version

check java version

From the results of the command you will know the version of java installed on your Ubuntu. The java version usually starts with a number 1. then proceed with the successfully installed version (in numbers) of Java. If there are other questions or comments regarding several ways to install Java on Linux above, please input them in the comments column below. Thank you.

Post a Comment for "2 Ways to Install Java on Linux Ubuntu for Beginners (Complete+Pictures)"