Table of Contents
This updated guide examines How to Install Java on Linux and organizes the essential facts, background, and practical takeaways in clear American English.
Method 1of 4:
Installing on Non-RPM Linux
Open theJava for Linux download page. You'll see several options listed here.
ClickLinux. It's a link in the middle of the page. Doing so will prompt the Java installation file to download.
- You can also click the Linux X64 version if you want to install 64-bit Java.
Note the file's name. The latest version of Java is version 8, but you also need the update version number, which is written in the file name after the "8u" section.
- For example, your file might be named "jre-8u151", signifying that it is version 8, update 151.
Open the command line. This step will vary depending on your version of Linux, but you can usually find the command line by opening the Terminal app or by clicking a bar at the top or bottom of the screen.
Change the installation directory. Typecdinto console, press the spacebar once, and then type in the path (e.g.,/usr/java/and press?Enter.
Enter the installation command. Type intar zxvf, press the spacebar once, and then type in the full file name. This will vary depending on the Java version and when you downloaded it.
- As of October 2017, you'd type intar zxvf jre-8u151-linux-i586.tar.
Press?Enter. Doing so will install Java on your computer in a folder entitled "jre1.8.0_[update]" where "[update]" is the update version number (e.g., 151).
Method 2of 4:
Installing on RPM Linux
Open theJava for Linux download page. You'll see several options listed here.
ClickLinux RPM. It's in the middle of the page. Doing so will prompt the Java for RPM installation file to download.
- You can also click the Linux RPM X64 version if you want to install 64-bit Java.
Note the file's name. The latest version of Java is version 8, but you also need the update version number, which is written in the file name after the "8u" section.
- For example, your file might be named "jre-8u151", signifying that it is version 8, update 151.
Open the command line. This step will vary depending on your version of Linux, but you can usually find the command line by opening the Terminal app or by clicking a bar at the top or bottom of the screen.
Enter the root command. Type insudo suand press?Enter. This will prompt the command line to request your user password.[1]
Enter your account password. Type in the password for your account and press?Enter. As long as you have root access on your account, doing so will allow you to install Java.
- If you don't have root access on your account, you'll need to enter the password for an account that does have root access.
Change the installation directory. Typecdinto console, press the spacebar once, and then type in the path (e.g.,/usr/java/and press?Enter.
Enter the installation command. Type inrpm -ivh, press the spacebar once, type in the full file name, and press?Enter. This will install Java on your computer.
- The file name will depend on when you downloaded the file. As of October 2017, you'd type inrpm -ivh jre-8u151-linux-i586.rpmand press?Enter.
- Upgrade the download. Type inrpm -Uvh jre-8u73-linux-i586.rpmand press?Enter. This will check for updates for the Java package and, if possible, apply them.
Method 3of 4:
Installing on Ubuntu (OpenJDK)
Open the command line. PressCtrl+Alt+Ton the keyboard, or click the black box icon with a white ">_" on it on the left side of the screen.
Enter the update command. Type insudo apt-get update && sudo apt-get upgrade -yand press?Enter. This will refresh the package list and install all available updates for you.
Enter your password if prompted. If asked for your user password, type it in and press?Enter.
Make sure that you don't have Java already installed. Type injava -versionand press?Enter. If you see a line that says "The program 'java' can be found in the following packages" appear, Java is not installed on your computer.
- If Java is installed, you'll see a line that reports the current version of Java instead.
Type in the installation command. Typesudo apt-get install default-jreinto the command line, then press?Enter. This will install Java on your Ubuntu computer in the default directory.
- If this doesn't work, try enteringsudo apt-get install openjdk-8-jdkinstead
Method 4of 4:
Installing on Ubuntu 16.04 via PPAs
First of all, this is a 3rd party package, your distro's maintainer can't audit this package, use with caution. That being said, first open a terminal by pressingCtrl+Alt+T.
Ensure you have an updated system. Type insudo apt-get update && sudo apt-get upgrade -y, you might get prompted for a password, type it in and press?Enter, no dots or asterisks will appear as you type, this is normal.
- While technically optional, this step is always recommended before installing anything, keeping your system updated will help prevent many problems.
Add the PPA repository to your system. Type insudo add-apt-repository ppa:webupd8team/java, and then press?Enter.
Update your package lists again. Type insudo apt-get updateand wait for the lists to be refreshed.
Install the package. Type insudo apt-get install oracle-java9-installer -y.
- You might get prompted for a password, type it in and press?Enter, no dots or asterisks will appear, this is normal.
Make Oracle's Java the default. In many Ubuntu derivatives, OpenJDK is set to be the default Java to be used, if you want Oracle's Java to be used by default you need to typesudo apt install oracle-java9-set-default.
FAQ
What is How to Install Java on Linux about?
It provides a structured overview of java, explains the main context, and highlights practical takeaways for readers.
Why does this topic matter?
Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.
How should readers use this information?
Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.
Reader Comments 0
Sign in with email or Google to join the discussion.