Blog

Install Oracle Java 8 on Ubuntu 18.04

Java is a programming language used to build Android apps and real life web applications like Gmail and Google Docs. This ubiquitous language can be installed onto an Ubuntu server and its what we’ll be teaching in this tutorial today.

Pre-flight

  • Open the terminal and log in as root. If you are logged in as another user, you will need to add sudo before each command.
  • Working on a Linux Ubuntu 16.04 server
  • No installations of previous Java versions

Install Java

Step 1: Updating your system

apt-get update && apt-get upgrade

Step 2: Install the Repo

First, install the repository, its provided by a third party and you’ll need to press enter to continue downloading. The Oracle Java (JDK) Installer automatically downloads and installs Oracle JDK8.

add-apt-repository ppa:webupd8team/java

Update your system once more
apt-get update

Step 3: Install Java 8

Using the command below will kickstart the Java Installer which will assist in our task. Press Y when prompted to continue.

apt-get install oracle-java8-installer

Once you come to the Installer page click OK and Yes to agree to their licensing and terms.

 

Step 4: Verify the Installation of Java 8

java -version

Example Output:
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

 

Set Java’s Home Environment

You may be looking to set Java’s home environment once we’ve installed it onto our server. To do that, lets first, let’s find Java’s path.

update-alternatives --config java

There is 1 choice for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
* 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode

Take the highlighted path and add the variable into your /etc/environment file. Add the JAVA_HOME path after any line that is already present.

vim /etc/environment

Once you are in the file type i to insert the needed line:
JAVA_HOME=”/usr/lib/jvm/java-8-oracle/jre/bin/java”

Save and exit the file by typing ESC followed by :wq and press enter. Afterward, use the source command to have the system recognize the changes in your file.

source /etc/environment

You’ll know the variable has been set correctly by calling the variable.

echo $JAVA_HOME
Example Output:
[email protected]:~# echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle/jre/bin/java

Related posts

Nhận dạng vân tay trong 30 phút

admin

Đối Vật Chất – Năng Lượng Vũ Trụ

admin

Phát hiện hang khổng lồ ở Venezuela

admin

Chuyến đi dài nhất của máy bay năng lượng Mặt Trời

admin

Nga chế tạo thành công robot phẫu thuật thế hệ mới

admin

Giải pháp đuổi thiên thạch đang lao vào trái đất

admin

Trung Quốc: Ổ dịch cúm gia cầm thứ 9

admin

Những "bậc thầy" phòng vệ trong tự nhiên

admin

Các giống chó chỉ khác nhau ở một gien

admin

Leave a Comment