Howtodojo logo
  • Home 
  • About 
  • Certifications 
  • Sample Database 
  • Cheatsheet 
  • Glossary 
  • Blog 
  • Tags 
  1.   Blog
  1. Home
  2. Blog
  3. How-to Install JDK 8 On Ubuntu 15.04

How-to Install JDK 8 On Ubuntu 15.04

Share via
Howtodojo
Link copied to clipboard

In this tutorial we'll learn how to install Java Development Kit version 8 on Ubuntu 15.04.

On this page
Overview   Install Java Development Kit (JDK) 8   Setting Up JAVA_HOME   Trying Java   Summary  
How-to Install JDK 8 On Ubuntu 15.04

Overview  

Java comes with two different version, JDK or Java Development Kit where you can develop Java app using these compilation of tools. Another version is JRE or Java Runtime Environment, if you only need to run Java application, you can use this. In this tutorial we’ll learn how to install Java Development Kit version 8 on Ubuntu 15.04.

Install Java Development Kit (JDK) 8  

We will install JDK 8 from Webupd8 PPA.

First let’s add webupd8 team PPA repository.

sudo add-apt-repository ppa:webupd8team/java
...
Press [ENTER] to continue or ctrl-c to cancel adding it

...
OK

You need to press enter to continue adding the webupd8team PPA repository. I truncate the output above to show you only the most important part.

Next, we’ll update local metadata to include webupd8 repository.

sudo apt-get update

Now, we can install Oracle JDK 8.

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

Package configuration. Choose OK

Accepting Oracle Binary Code License Terms. Choose Yes

After installing Java 8, you can check the current java version by running command below :

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

We confirmed that we already have JDK 8 installed.

Setting Up JAVA_HOME  

Let’s check first where java installed

$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-oracle/jre/bin/java
Nothing to configure.

from the output above we can see that the JAVA_HOME that we need is /usr/lib/jvm/java-8-oracle/jre/

On /etc/environment, add JAVA_HOME on the last line :

JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/"

Trying Java  

Create a new file with name HelloWorld.java with contents below :

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

From terminal, run :

javac HelloWorld.java

If no error, javac should produce HelloWorld.class. To run this file you can use java

java HelloWorld

Summary  

We learned how to install JDK 8 on Ubuntu 15.04, setting up JAVA_HOME environment variable that usually needed by Java based application. We also learned how to compile simple Java app and run it.

 How-to Install Oracle JDK 7 On Ubuntu 15.04
10 Sites To Check Your DNS Health 
On this page:
Overview   Install Java Development Kit (JDK) 8   Setting Up JAVA_HOME   Trying Java   Summary  
Follow me

We publish tutorials, tips and tricks about Linux, open source, cloud computing, and infrastructure

     
Copyright © 2012 - 2025 howtodojo.com. |
Howtodojo
Code copied to clipboard