ubuntu how to install java

image_pdfimage_print

This tutorial will cover the installation of

These instructions will also work on Debian and Linux Mint.

Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit, open up a terminal and run the following command below.

Java Version

If you have OpenJDK installed on your system it may look like this

If you have OpenJDK installed on your system, you have the wrong vendor version of Java installed for this exercise.
Completely remove the OpenJDK/JRE from the system if necessary
This will prevent system conflicts and confusion between different vendor versions of Java. For example, if you have the OpenJDK/JRE installed on your system, you can remove it by typing the following at the command line:

This command will completely remove OpenJDK/JRE from your system
Create a directory to put your Oracle Java JDK and JRE binaries in, open up a terminal and create the directory /usr/local/java

Download the Oracle Java JDK/JRE for Linux. Make sure you select the correctcompressed binaries for your system architecture 32-bit or 64-bit (which end in tar.gz).

For example, if you are on Ubuntu Linux 32-bit operating system download 32-bit Oracle Java binaries.
For example, if you are on Ubuntu Linux 64-bit operating system download 64-bit Oracle Java binaries.

Copy the Oracle Java binaries into the /usr/local/java directory
In most cases, the Oracle Java binaries are downloaded to: /home/“your_user_name”/Downloads.

32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:

Run the following commands on the downloaded Oracle Java tar.gz files. Make sure to do this as root in order to make them executable for all users on your system.
32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:

Unpack the compressed Java binaries, in the directory /usr/local/java

64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:

Double-check your directories. At this point, you should have two uncompressed binary directories in /usr/local/java for the Java JDK/JRE listed as:

Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.this command notifies the system that Oracle Java JRE is available for use

this command notifies the system that Oracle Java JDK is available for use

this command notifies the system that Oracle Java Web start is available for use,
Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java

Note your system-wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system.
Test to see if Oracle Java was installed correctly on your system. Run the following commands and note the version of Java:

This command displays the version of java running on your system
A successful installation of 32-bit Oracle Java will display

You should receive a message which displays:

This command lets you know that you are now able to compile Java programs from the terminal.
You should receive a message which displays:
javac 1.7.0_05
A successful installation of Oracle Java 64-bit will display
java -version
This command displays the version of java running on your system
You should receive a message which displays:

 Congratulations, you just installed Oracle Java on your Linux system.

Now reboot your Ubuntu Linux system.
Afterwards, your system will be fully configured for running and developing Java programs.