How to install Java for Ubuntu, Linux Mint and Debian


Back to the home page

Are you visiting this website with Chrome or Chromium? Then you might see an unjustified warning.


Web browsers block Java plug-in: how to unblock it in Firefox 52

1. Web browsers are starting to block Java plug-ins, because of security concerns. In Firefox 52 it's still possible to undo that blockade. As follows:

- In the URL bar (address bar) of Firefox 52, type: about:config
Press Enter.
- Click on the button I accept the risk!
- Right-click on the list of parameters. Select New - Boolean.
- In the dialogue box, enter the parameter name plugin.load_flash_only and click OK.
- In the value dialogue box, confirm the pre-selected Boolean value false.
- Close the about:config window.
- Close Firefox and restart it.
- You're done!

Do you wish to remove that Boolean string again? Then do this: right-click on the parameter line - Reset. Then close Firefox and launch it again.

Primary choice: OpenJDK and not Oracle (Sun) Java

2. For Java there's a good open source application available: OpenJDK and the IcedTea plug-in. They are available in the regular Ubuntu repositories and receive regular security updates. For many people this Java is adequate.

That's why the closed source Oracle (Sun) Java Runtime Environment (JRE) has been removed from the official software repositories of Ubuntu. It has even disappeared from the Partners repository.

Do the following in order to install openJDK and the IcedTea plug-in:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste: rapidly click three times on the blue line, in order to select the entire line).
sudo apt-get install icedtea-8-plugin

Press Enter.

Type your password. You won't see anything, not even dots, this is normal.
Press Enter.

Now OpenJDK will be installed automatically as well, along with the plugin.

So: OpenJDK and the IcedTea Plug-in are adequate for many people.

However....

How-to for Oracle (Sun) Java JRE

3. However, some Ubuntu users will still need Oracle (Sun) Java JRE. For those I have written this manual.

Tip 1: you can use this tutorial in Linux Mint and Debian as well.

Tip 2: for openSUSE, use this slightly different how-to.

When you want JRE in Ubuntu, you can use a manual method. A manual method has the advantage that you don't have to rely on shady third-party repositories, which may be unsafe, either by maliciousness or by simple neglect (outdated insecure version).

The repository of duinsoft.nl

3.1. There is a positive exception: the repository of duinsoft.nl, which is owned by a respected member of the Dutch Ubuntu community. This contains a script that will always pull the latest Oracle Java from the Oracle website, and install it in your system.

Do you prefer the manual way? Then read on below; it's almost as easy as using the Duinsoft repo.


Installing manually is not hard, although you have to use the terminal for that (yikes!). Precision is important: it only succeeds when you follow the instructions exactly.

Updates: check for them yourself!

4. A manually installed application receives no updates from Ubuntu or Mint! For JRE, you'll have to take care of security updates yourself.

For that, you'll regularly want to check the verification website of Java, to see if there are updated versions available. JRE itself won't alert you (it only does that in Windows)

Oracle issues critical security updates on a fixed time schedule (emergencies excepted). On that page, look for the category Oracle Java SE Critical Patch Updates. It may be handy to write those dates in your agenda.

Only for 64 bit

5. The default generic version of Ubuntu and Mint is 64-bit, and the 32-bit ecosystem is crumbling everywhere. So the how-to is only for 64-bit.

If you're unsure whether your system is 64-bit, check it like this.

HOW-TO FOR 64-BIT UBUNTU AND LINUX MINT


6. The how-to below is a step-by-step approach which relies on the terminal. Copy and paste the terminal commands carefully.

Remove the browser plug-in of the old version

6.1. First you'll want to remove the browser plug-in of the old JRE or openJDK (if you have it). Only the browser plug-in needs to be removed! Otherwise unwanted side effects may occur.

When the old JRE has been installed manually in /opt/java, see the instruction at the bottom of this column (under the header Removal).

When you don't have an old JRE, you probably have openJDK and the IcedTea browser plug-in. The IcedTea browser plug-in should be removed; openJDK itself can remain on your hard disk.

Like this:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Use copy/paste to transfer the following blue line to the terminal, in order to avoid typo's:
sudo apt-get remove icedtea-8-plugin

Press Enter.

Type your password. You won't see anything when you type it, not even dots will show, this is normal. Press Enter.

Get JRE

6.2. Get the right file from the Java website: http://www.java.com

For 64-bit you want Linux x64. The name of this file ends on .tar.gz. Do not pick Linux x64 RPM (file name ends on x64.rpm), because RPM is not built for Ubuntu and Linux Mint, but for other Linux distro's.

Note: Store the file in the folder Downloads. So in:
/home/your-user-name/Downloads 

Firefox puts downloaded files there by default, but not all web browsers do it like that. 

For example, user John should place the file in:
/home/john/Downloads 
When in doubt, check it.

This is important for the terminal commands that you'll execute later on; otherwise they won't be correct.

The how-to continues in the column on the right.

(continued in the column on the right)


This website is being sponsored by Google Ads.

Are you using an ad blocker? Then you're also blocking my earnings from advertisements....

If you wish to support my website, you can configure your ad blocker to make an exception for this website. Or you can make a donation (and get free goodies).

Thanks in advance....


Install JRE (64-bit)

6.3. Note: the terminal commands in this how-to possibly refer to an older version of JRE. When there's a newer version, you can simply adapt the file names in the terminal commands.

This how-to has been written for JRE 8 update 121 (64 bit version).


A. Create a new subfolder in the folder opt, by means of a terminal command:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Use copy/paste to transfer the following blue line to the terminal, in order to avoid typo's:
sudo mkdir -p -v /opt/java/64

Press Enter.

Type your password. You won't see anything when you type it, not even dots will show, this is normal. Press Enter.


B. Now go to the Downloads folder and unpack the compressed JRE file that you just downloaded, with the following combined command:

Use copy/paste) to transfer the following blue line to the terminal (it's one line):

cd Downloads && tar xvzf ~/Downloads/jre-8u121-linux-x64.tar.gz

Press Enter.


C. Move the unpacked contents of the JRE file into the system folder that you created in step A, with the following command:

Copy/paste the following line into the terminal:
sudo mv -v ~/Downloads/jre1.8.0_121 /opt/java/64

Press Enter.


D. Now you'll want to tell the system, that there's a new Java version available:

Copy/paste the following blue line into the terminal (this is one line):

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.8.0_121/bin/java" 1

Press Enter.

Note: are you updating from a previous Java version, which you have removed manually? Then you'll need to execute the above command twice, because you'll get an error message the first time.


E. Tell the system, that the new Java must be the default:

Copy/paste the following line into the terminal (it's one line):

sudo update-alternatives --set java /opt/java/64/jre1.8.0_121/bin/java

Press Enter.


F. Installing the Firefox plugin is simple. First execute the following command, in order to create a certain folder (if it doesn't exist already):

Copy/paste into the terminal:
mkdir -v ~/.mozilla/plugins

Press Enter.

If it exists already, you'll see a notification of that.


G. Now remove the IcedTea plugin, if it has been installed:

Copy/paste into the terminal:
sudo apt-get remove icedtea-8-plugin

Press Enter.

If it's not there to begin with, you'll get a notification of that.


H. Remove an older version of the Java plugin:

Copy/paste into the terminal:
rm -v ~/.mozilla/plugins/libnpjp2.so

Press Enter.

If it's not there to begin with, you'll get a notification of that.


I. Now you can install the plugin, by creating a symbolic link (you tell Firefox, where the plugin is located):

Copy/paste into the terminal (this is one line):
ln -s /opt/java/64/jre1.8.0_121/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Press Enter.


J. Now close and restart Firefox. Check whether everything has succeeded. Type in the URL bar of Firefox (not in the terminal!):

about:plugins

Press Enter.

And scroll down, until you see something approximately similar to this:
Java(TM) Plug-in (followed by version number)

You can also use this website (note that this website doesn't work until you've enabled the Java plugin in Firefox, because for security reasons Firefox disables it by default): http://java.com/en/download/installed.jsp

Only enable the plugin when needed

6.4. Java is frequently under attack from malicious software on websites. Java is platform independent, so Linux is vulnerable, too. Therefore it's better to disable the plugin and only enable it for a short while, whenever you need it. You can do that as follows.

Note: this only applies to Java. There's also Javascript, which is much safer. So there's no need to disable Javascript as well.

Tame disk usage with the Java Control Panel

6.5. By default, Java allows itself to use a crazy maximum amount of disk space for the cache (what were the developers smoking?). You can limit that as follows:

Call up the Java Control Panel as follows (in each user account):

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Copy/paste into the terminal:
/opt/java/64/jre1.8.0_121/bin/ControlPanel

Press Enter.

Temporary Internet Files - Settings... Disk Space: limit it to 50 MB.
Click Delete Files... OK - OK - Apply - OK.

Repeat this in each user account.

Do you have a Solid State Drive (SSD)? Then disable this cache entirely, as you'll want to limit write actions as much as possible for an SSD.

Note: this command is only for JRE 8 update 121. You'll need to adapt it when you use another version.

Other user accounts: repeat three commands and limit disk usage

6.6. Are there any other user accounts on the computer? Then repeat the following three terminal commands in each user account:

rm -v ~/.mozilla/plugins/libnpjp2.so


and then (in case the plugins folder doesn't exist yet):

mkdir -v ~/.mozilla/plugins


and then:

ln -s /opt/java/64/jre1.8.0_121/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Finally, use the Java Control Panel in those other user accounts, to limit the maximum disk usage of the cache (see step 5.5).

Removal

6.7. Do you wish to remove JRE again? It's very easy, to remove a manually installed JRE. As follows:

a. Remove the folder /opt/java and what's in it, by means of the following terminal command:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Copy/paste into the terminal:
sudo rm -r -v /opt/java

Press Enter.

Type your password. You won't see anything when you type it, not even dots will show, this is normal. Press Enter.

b. Then in the terminal, in order to remove the Java plugin:

Copy/paste into the terminal:
rm -v ~/.mozilla/plugins/libnpjp2.so

Press Enter.

c. Finally, restart your web browser.

Note: are there multiple user accounts? Then repeat step b in those other accounts.

Updating an older version

6.8. It's easy to update an older version. Proceed as described above, under the header "Removal". Then install the new version.

Want more tips?

7. Do you want more tips and tweaks for Ubuntu and Linux Mint? There's a lot more of them on this website!

For example:

Speed up your Ubuntu

Firefox: improve it

Chrome: tweak it

Libre Office: tune it

Solid State Drive (SSD): optimize it

To the content of this website applies a Creative Commons license.


Comments