Check Java Installation & Install Java on Ubuntu - Guide

Checking for and Installing Java on Ubuntu
Typically, a fresh installation of Ubuntu does not include Java or the Java Runtime Environment (JRE). However, certain applications, such as Minecraft, may require it to function correctly. This guide will demonstrate how to determine if Java is already present on your system and, if not, how to install it efficiently.
It's important to be aware that Java can present security vulnerabilities. Therefore, taking appropriate protective measures is crucial. If Java is necessary for the programs or games you utilize, we recommend reviewing our article detailing how to safeguard yourself against Java-related security risks.
Important Note: When instructed to enter text in this guide, do not include the quotation marks, unless explicitly stated.
Verifying Java Installation
To ascertain whether any version of Java is currently installed, execute the following command at the terminal prompt and press Enter:
java –version
If the output resembles the image shown below, it indicates that Java is not installed. The system will display a list of available Java packages and the corresponding installation command.
Prior to installing Java, it is advisable to update the package lists. This ensures you have access to the latest versions. Enter the following command at the prompt and press Enter:
sudo apt-get update
This command refreshes the package lists available within Ubuntu. You will be prompted to enter your user password; do so and press Enter.

Installing Java
Once the update process is complete, select the desired Java package from the displayed list. For example, to install version 6, use the following command at the prompt and press Enter:
sudo apt-get install openjdk-6-jre-headless
Remember to substitute the final portion of the command with the specific package name you have chosen from the list.

As you recently used sudo for another command, you may not be prompted for your password again.
The installation progress will be displayed, followed by an estimate of the disk space required. When prompted to continue, type “y” and press Enter to proceed.

Verifying the Installation
After the installation is finished, re-check the Java version by typing “java –version” at the prompt and pressing Enter. The output should now display information about the Java version you just installed.

Disabling Browser Integration
If you only require Java for desktop applications and games, it is recommended to disable Java browser integration for enhanced security. Refer to our dedicated article for detailed instructions on how to accomplish this.