How To Install Java (JRE or JDK) on Ubuntu 16.04

Install Java (JRE or JDK) on Ubuntu 16

In this tutorial we will show you how to install and configuration of java JRE or JDK on your Ubuntu 16.04 server. Many programs and scripts that require java to run it, but usually Java is not installed by default on VPS or Dedicated Server. This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation JRE (Java Runtime Environment) and JDK (Java Development Kit) on Ubuntu 16.04.

Install Java (JRE or JDK) on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

After your server has been fully updated, verify if java is installed or not:

java -version

If there is no java package installed ye, output will be something like:

The program 'java' can be found in the following packages:

* default-jre
* gcj-4.9-jre-headless
* gcj-5-jre-headless
* openjdk-7-jre-headless
* gcj-4.8-jre-headless
* openjdk-6-jre-headless
* openjdk-8-jre-headless
* openjdk-9-jre-headless
Try: apt install <selected package>

Step 2. Installing Java (JRE or JDK).

Once you have verified if Java is installed or not, choose the type of Java installation that you want with one the following:

sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk

Another alternative Java install is with Oracle JRE and JDK. However, we would need to install additional repositories for a proper installation:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java

Then, you will need to fully update the system with the following command and install it:

sudo apt-get update
sudo apt-get install oracle-java8-installer

Step 3. Verify Installed Java Version.

java -version

Result:

java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

Step 4. Setup JAVA_HOME on Ubuntu 16.04.

Since many programs now days need a JAVA_HOME environment variable to work properly. We will need to find the appropriate path to make these changes. With the following command, you can view your installs and their path:

sudo update-alternatives --config java
sudo nano /etc/profile

Now that you are in the user profile file, add the following code, along with the Path of your installation from the previous step, to the bottom. ( Example: JAVA_HOME=”YOUR_PATH”):

export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-1.b16.el7_1.x86_64"

Reload the file so all your changes could take effect with the following command:

source /etc/profile

Verify that your implementations are correct with the following command:

echo $JAVA_HOME

Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java (JRE or JDK) on Ubuntu 16.04 Xenial Xerus system. For additional help or useful information, we recommend you to check the official Java web site.

How to install Java on Ubuntu

How to install Java on Ubuntu

There are many programs and scripts that require java to run it, but usually Java is not installed by default on VPS/Dedicated Server. In this tutorial we are going to learn a simple step to install Java on your Ubuntu machine.

Java is at the heart of our digital lifestyle. It’s the platform for launching careers, exploring human-to-digital interfaces, architecting the world’s best applications, and unlocking innovation everywhere—from garages to global organizations.

Java technology allows you to work and play in a secure computing environment. Upgrading to the latest Java version improves the security of your system, as older versions do not include the latest security updates.

Java allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few.

install Java on Ubuntu

First step, update apt-get repository

 apt-get update

Second step, install java run time

 apt-get install default-jre

Third step, install java development kit

 apt-get install default-jdk

Fourth step, check java installation

 java -version

Result:

java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

OK that’s all for now the tutorial to install Java Runtime and Java Development Kit on Ubuntu.

Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java on Ubuntu system. For additional help or useful information, we recommend you to check the official Java web site.

You Might Also Like: How To Install Oracle Java on Ubuntu 17.04

How To Install Java JDK 8 on CentOS 6

install java jdk on centos 6

There are many programs and scripts that require java to run it, but usually Java is not installed by default on VPS or Dedicated Server. This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation Java JDK 8 on CentOS 6.

Step 1. Remove the Java 1.6 or 1.7 have been installed already, you can uninstall them using the following commands.

yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk

Step 2. Downloading latest Java archive.

Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from shell:

### CentOS 64-Bit ###
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-x64.tar.gz"
tar xzf jdk-8u40-linux-x64.tar.gz
### CentOS 32-Bit ###
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-i586.tar.gz"
tar xzf jdk-8u40-linux-i586.tar.g

Step 3. Install JAVA using alternatives.
After extracting archive file use alternatives command to install it. alternatives command is available in chkconfig package:

# cd /opt/jdk1.8.0_40/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 2
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*  1           /opt/jdk1.8.0/bin/java
 + 2           /opt/jdk1.8.0_25/bin/java
   3           /opt/jdk1.8.0_40/bin/java
Enter to keep the current selection[+], or type selection number: 3

At this point JAVA 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives:

alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_40/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_40/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_40/bin/jar
alternatives --set javac /opt/jdk1.8.0_40/bin/javac

Step 4. Verify Installed Java version.

# java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Step 5. Setup global environment variables.

We can easily set the environment variables using the export command as shown below:

Setup JAVA_HOME Variable:

 export JAVA_HOME=/opt/jdk1.8.0_40

Setup JRE_HOME Variable:

 export JRE_HOME=/opt/jdk1.8.0_40/jre

Setup PATH Variable:

 export PATH=$PATH:/opt/jdk1.8.0_40/bin:/opt/jdk1.8.0_40/jre/bin

Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java (JDK) 8 on CentOS 6 system.

How To Install Java JDK 8 on Ubuntu 14.04

install java jdk on ubuntu

In this tutorial we will show you how to install and configuration of Java on your Ubuntu 14.04 server. There are many programs and scripts that require java to run it, but usually Java is not installed by default on VPS or Dedicated Server.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Java JDK 8 on a Ubuntu 14.04 server.

Install Java JDK 8 on Ubuntu 14.04

Step 1. Remove the OpenJDK from the system, if you have it already installed.

 sudo apt-get remove --purge openjdk*

Step 2. Add the webupd8team Java PPA repository in your system.

 sudo add-apt-repository -y ppa:webupd8team/java

Step 3. Install Java JDK 8

After added the PPA, run commands below one by one to install Java JDK 8:

sudo apt-get update
sudo aptitude -y install oracle-java8-installer

Step 4. Verify Installed Java Version.

 java -version

Result:

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java (JDK) 8 on Ubuntu 14.04 system. For additional help or useful information, we recommend you to check the official Java web site.