How to install Java for Linux Mint


Back to the home page


Contents of this page:


Web browsers are blocking the Java plug-in

1. Nowadays, all major web browsers are blocking Java plug-ins, because of grave security concerns. It's advisable to leave it at that.

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

Primary choice: OpenJDK and not Oracle (Sun) Java

2. For Java there's a good open source application available: OpenJDK. It's available in the regular Ubuntu repositories and receives 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 make sure that you have openJDK (it's present by default in Mint, but you may have removed it):

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 default-jre

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

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

So: OpenJDK is adequate for most people.

However....

How-to for Oracle (Sun) Java JRE

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

When you want JRE in Mint, 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 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 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 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 page (under the header Removal, item 6.6).

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 typos:

sudo apt-get remove icedtea*

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

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 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.

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 271 (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 into the terminal, in order to avoid typos:

sudo mkdir -p -v /opt/java/64

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.


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 into the terminal (it's one line):

cd Downloads && tar -xvzf ~/Downloads/jre-8u271-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_271 /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_271/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_271/bin/java

Press Enter.

Tame disk usage with the Java Control Panel

6.4. 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_271/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 271. You'll need to adapt it when you use another version.

Other user accounts: limit disk usage

6.5. Are there any other user accounts on the computer? Then use the Java Control Panel in those other user accounts, to limit the maximum disk usage of the cache (see step 6.4).

Removal

6.6. 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 when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

Updating an older version

6.7. It's easy to update an older version. Proceed as described above, under the header "Removal" (item 6.6). Then install the new version.

Want more tips?

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

For example:

Speed up your Linux Mint!

Clean your Linux Mint safely

Avoid 10 fatal mistakes


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

Back to the home page

Disclaimer