Sistema de blogs Diarium
Universidad de Salamanca
Pablo Gallardo's Blog
My professional web log about IT, Cybersecurity & Project Management
 

How to install JRE or JDK in Ubuntu

This post explains how to install or update Java components JRE or JDK in operating system Ubuntu.

It may be compatible with other Debian-like or Ubuntu-like Linux distros, like Linux Mint, etc.

 

Step-by-step Procedure

1. Install repository

Open a terminal.

Install repository from command line:

sudo add-apt-repository ppa:<repositoryaddress>

The repositories I found were (you need to substitute <repositoryaddress> by the corresponding address):

Neither of these repositories are official and I do not have feedback about them (apart from what I have read in some forums), so use them at your own risk.

So for example, to install the openjdk-r/ppa repository:

sudo add-apt-repository ppa:openjdk-r/ppa

2. Update apt-get

Run this command on terminal:

sudo apt-get update

3. Install JDK

Install the desired JDK from terminal.

If for example, you want to install OpenJDK 15:

sudo apt-get install openjdk-15-jre

sudo apt-get install openjdk-15-jdk

5. Check the Java version used as default

Go to the terminal and type:

java -version

Your current Java version must be displayed.

4. Select the default JDK version to use

In my case, I was updating from OpenJDK 11 to OpenJDK 15, and I did not need to apply any change in order to use the latest OpenJDK version. It was updated automatically.

You can also install multiple version of JDK, mixing OpenJDK and Oracle versions. Then you can use the command update-java-alternatives to switch between installed version:

# list available jdk
update-java-alternatives --list

# use jdk7
sudo update-java-alternatives --set java-7-oracle

# use jdk8
sudo update-java-alternatives --set java-8-oracle

 

External references

pmgallardo

About pmgallardo

I studied Computer Science at University of Salamanca. Since then, I have been working first as developer and then as SAP consutant. This blog is about problems I dealt when using computers, and more important, the solutions I found. Whenever I am on an issue and suddenlly I have a flash that leads me to a solution, I document my discoveries in a post.

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

No comments yet.

Leave a Reply


*

Política de privacidad
Studii Salmantini. Campus de excelencia internacional