SEARCH

How-To Geek

How to Find Out if Java is Installed in Ubuntu and How to Install It

00_lead_image_java_in_ubuntu

By default, Ubuntu does not come with Java (or the Java Runtime Environment, JRE) installed. However, you may need it for some programs or games like Minecraft. We will show you how to quickly and easily check if Java is installed and how to install it.

RELATED ARTICLE
How to Protect Yourself From Java Security Problems if You Can’t Uninstall It
For years, Java has been the top source of browser exploits. Even after a recent emergency patch, Java is still... [Read Article]

Note that Java can be vulnerable to security problems, and you should protect yourself. If you really need Java for programs or games that you run, read our article about protecting yourself from Java security problems.

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

To check which version, if any, of Java is installed, type the following at the prompt and press Enter.

java –version

If you get a result similar to the one shown in the following image, you do not have Java installed. The list shows you which packages in your system have Java available and the command for installing java is displayed.

However, before installing Java, let’s make sure all the packages are up to date. Type the following at the prompt and press Enter.

sudo apt-get update

This updates all the packages in available in Ubuntu. Type your password at the prompt and press Enter.

01_check_java_version

When the update is done, choose which a package from the list to install java. In our example, we installed version 6. Type the following command at the prompt and press Enter.

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

Replace the last part of the command after install with the package from the list that you chose.

02_command_to_install_java

Because you recently ran another command as root using sudo, you are not asked for your password again.

The progress of the installation displays and then a message displays saying how much disk space will be used. When asked if you want to continue, type a “y” and press Enter.

03_do_you_want_to_continue

When the installation is done, check the version of Java again by typing “java –version” at the prompt and pressing Enter. You’ll see a result similar to the following indicating the version of Java you just installed.

04_check_version_again

If you only need Java for desktop programs and games, it’s a good idea to disable Java browser integration. Again, see our article for instructions on how to do this.

Lori Kaufman is a freelance technical writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 06/25/14