How to install Java in Ubuntu?
Tags: ubuntu, installation, javaopenjdksoftware
Published: 2021-11-25 17:03:14

---
title: How to install Java in Ubuntu?
published: true
date: 2021-11-23 15:57:01 UTC
tags: Ubuntu,installation,javaopenjdksoftware
canonical_url: https://stackallflow.com/ubuntu/how-to-install-java-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">java</span><span style="font-size: 1.2em; color: initial;">openjdk</span><span style="font-size: 1.2em; color: initial;">software installation</span></p>
</header>

How do I install Java, including in my browser, so websites with Java work?

#### Accepted Answer

There are several implementations of Java. The three most common implementations when talking about it for Ubuntu are:

- **OpenJDK** : The primary goal of the OpenJDK project is to produce an  
open-source implementation of the [Java SE](http://en.wikipedia.org/wiki/Java_Platform,_Standard_Edition) Platform (6 and 7). This is  
the default version of Java that Ubuntu uses and is the easiest to  
install.
- **Sun Java** : Sun Java is the reference implementation for Java 6. Its support [has been discontinued](https://askubuntu.com/questions/64515/will-suns-java-be-available-from-canonicals-partner-repository/88035#88035) in Ubuntu.
- **Oracle Java** : Oracle Java is the OpenJDK Java Se Platform version 7 implementation from Oracle. Oracle introduced with this implementation [a license](http://java.com/en/download/faq/distribution.xml#eula) that prevents distribution.

Since Ubuntu 11.10 (Oneiric Ocelot) and [due to license issues](https://wiki.ubuntu.com/JavaTeam) Ubuntu will no longer distribute Oracle’s JDK and [JRE](http://en.wikipedia.org/wiki/Java_Virtual_Machine#Execution_environment). Also, previous versions supplied on PPAs suffer from security issues and are not recommended to be installed on any Ubuntu system.

There are no more supported .deb [releases from Ubuntu](https://help.ubuntu.com/community/Java) with reference to Sun Java or Oracle Java, Ubuntu officially supports OpenJDK and OpenJRE implementation of Java which is the base for Oracle’s own implementation.

OpenJRE is the official implementation of Java Runtime Environment (JRE) for your Ubuntu systems and should suffice to run any Java program that you might require and it’s included in the main repository and it’s easily installable.

### OpenJRE

By opening a terminal and typing

```
sudo apt-get install default-jre

```

this installs `openjdk-11-jre` (at the time of writing this, you may install a newer java version in the future, which is now, if it installs a different openjdk version I guess)

The `openjdk-11-jre` package contains just the Java Runtime Environment. If you want to develop Java programs then install the `default-jdk` package:

* * *

Also important is to install the wrapper for supporting Java applications on your web browser, the _Iced-Tea Java Plugin_.

### IcedTea Plugin

[![Install via the software center](https://hostmar.co/software-banner)](https://apps.ubuntu.com/cat/applications/icedtea-plugin)

Or via a terminal

```
sudo apt-get install icedtea-plugin

```

Or look for `icedtea-plugin` in the Ubuntu Software Center.

* * *

To make sure that you are running the correct version of Java, use this command to set your choice:

```
sudo update-alternatives --config java

```

`java -version` should display the choice you previously made.

* * *

**If you need to install OpenJDK-JRE 6 or OpenJDK-JDK 6**

[`openjdk-6-jre`](http://apt.ubuntu.com/p/openjdk-6-jre) (click to install) is available for installation for [Ubuntu 8.04](https://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Ubuntu_8.04_LTS_.28Hardy_Heron.29) (Hardy Heron) and up.

Install it with

```
sudo apt-get install openjdk-6-jre

```

Or if you need the developers’ package, [`openjdk-6-jdk`](http://apt.ubuntu.com/p/openjdk-6-jdk) (click to install), install it with:

```
sudo apt-get install openjdk-6-jdk

```

A version of the [`icedtea-plugin`](http://apt.ubuntu.com/p/icedtea6-plugin) (click to install) is also available to install if you are going to use OpenJDK 6.

Install it with:

```
sudo apt-get install icedtea6-plugin

```

* * *

**If you really want to use Oracle’s Java SE Platform** , see _[How can I install Sun/Oracle’s proprietary Java JDK 6/7/8 or JRE?](https://askubuntu.com/q/56104/176889)_.

The post [How to install Java in Ubuntu?](https://stackallflow.com/ubuntu/how-to-install-java-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).