5 Ways to Install Java on Linux

Table of contents:

5 Ways to Install Java on Linux
5 Ways to Install Java on Linux

Video: 5 Ways to Install Java on Linux

Video: 5 Ways to Install Java on Linux
Video: How to run exe files on Mac? 2024, May
Anonim

With Java, you can run cross-platform applications on Mac OS-X, Linux, and Windows (as well as other operating systems) without having to modify them. You can install Java on a GNU/Linux machine easily and there are also many ways for users with very little technical knowledge. Just because you have a Linux computer, doesn't mean you should miss out on a great application!

Step

Method 1 of 5: Manually Installing Java (Non-RPM Method)

This is a common method that can also be run on GNU/Linux clones that don't support RPM. This method does not require computer administrator approval and you can install multiple versions of Java on one computer.

Install Java on Linux Step 1
Install Java on Linux Step 1

Step 1. Download the JDK

  • Click the "Download" link above the Java Platform (JDK) 7u9.
  • Accept the license and proceed to the next step.
Install Java on Linux Step 2
Install Java on Linux Step 2

Step 2. Choose the right download file

Under "Product/File Description" you must select the Linux option that suits your computer. For example, if you are running Linux x86 (32 bit), you need to select the “*.tar.gz” version.

Install Java on Linux Step 3
Install Java on Linux Step 3

Step 3. Download the file in.gz format

Save the file in your GNU/Linux machine.

Install Java on Linux Step 4
Install Java on Linux Step 4

Step 4. Open the directory where the downloaded file is stored

You don't need to be root (a user who has full access to the computer), you just need to have access to the directory you will use to store Java programs. If your administrator doesn't support it, you can save Java in the Home directory or (better) the Shared Network directory.

Install Java on Linux Step 5
Install Java on Linux Step 5

Step 5. Open the downloaded file

For example, you can do this in your Home directory. Opening the file will create a new directory titled “jdk1.7.0_09”. Now, Java is installed.

  • The Java JRE is more free and can be moved easily from one place to another by simply copying the entire file.
  • You can install different JREs this way. JREs in different versions can run together and can be used if there is software that requires an older version to run.
Install Java on Linux Step 6
Install Java on Linux Step 6

Step 6. Run Java

Java programs that you can run are located in the subdirectory entitled "bin". This installation method will not form the usual Java command. You will have to do this manually or always include the full path in your startup scripts.

Method 2 of 5: Manual RPM Method

This method is the "more correct" way to install Java because it allows the installer to check for missing dependencies on the library system. However, this method is not applicable in all versions and some may fail even on systems that support RPM. (Although the current Java installer is more self-contained and the requirements are usually few.)

Install Java on Linux Step 7
Install Java on Linux Step 7

Step 1. Download the JDK

  • Click the "Download" link above the Java Platform (JDK) 7u9.
  • Accept the license and proceed to the next step.
Install Java on Linux Step 8
Install Java on Linux Step 8

Step 2. Choose the right download file

Under "Product/File Description" you must select the Linux option that suits your computer. For example, if you are running Linux x86 (32 bit), you need to select the “*.rpm” version, for example “jdk-7u9-linux-i586.rpm”.

Install Java on Linux Step 9
Install Java on Linux Step 9

Step 3. Download the.rpm file

Save the file into your GNU/Linux machine.

Install Java on Linux Step 10
Install Java on Linux Step 10

Step 4. Log in as root and go to the directory where the downloaded files are stored

You can also become root by running SU and entering the superuser password.

Install Java on Linux Step 11
Install Java on Linux Step 11

Step 5. Install the RPM file

Type rpm -ivh filename.rpm where filename is the name of your.rpm file. (Like jdk-7u9-linux-i586.rpm).

  • You may get a message stating that the program “rpm” is not installed.
  • If the problem is that the program “rpm” is not installed, you will need to install it by typing sudo apt-get install rpm. Enter your password and the program is ready to run.
Install Java on Linux Step 12
Install Java on Linux Step 12

Step 6. Create a symbolic link

If you want to run this version of the Java interpreter or compiler from any existing directory on your GNU/Linux system, you'll need to create some symbolic links:

  • sudo ln -s -v jdk1.7.0_09/bin/java /usr/bin/java
  • sudo ln -s -v jdk1.7.0_09/bin/javac /usr/bin/javac
  • Remember, with this method, you may find broken dependencies. It's better to use an installer package that can handle all dependencies because you can't use Java until all errant dependencies are handled.

Method 3 of 5: Installing Java on Ubuntu Using the GUI Package Manager

Install Java on Linux Step 13
Install Java on Linux Step 13

Step 1. Open the package manager

You can also use Synaptic or Adept Manager.

Install Java on Linux Step 14
Install Java on Linux Step 14

Step 2. Install Open JDK

The Java JDK and JRE are not available for installation via the Package Manager GUI. Instead, you must install the Open JDK.

  • Do a search for openjdk-7-jdk.
  • Select openjdk-7-jdk for installation. Depending on the existing package manager, you will be asked to choose to install the required dependencies or the package manager will automatically select the required dependencies without any confirmation. For example, "openjdk-7-jre" is already selected by the Synaptic Package Manager. If you want to use Java as a plugin in your browser, select the option to install "icedtea-7-plugin".
Install Java on Linux Step 15
Install Java on Linux Step 15

Step 3. Apply changes

Click the button to apply the changes. Depending on the package manager you are using, a window will appear asking for your approval to apply the changes.

Install Java on Linux Step 16
Install Java on Linux Step 16

Step 4. Wait for Java to install successfully

Method 4 of 5: Installing Java on Ubuntu Using the Console

Install Java on Linux Step 17
Install Java on Linux Step 17

Step 1. Enter one of the commands below into your console program:

  • sudo apt-get install openjdk-7-jdk openjdk-7-jre (if you don't want to install the plugin on your browser)
  • sudo apt-get install openjdk-7-jdk openjdk-7-jre icedtea-7-plugin (if you want to install the plugin on your browser)
  • apt-get can automatically handle existing dependencies and provide a list of changes for confirmation.
Install Java on Linux Step 18
Install Java on Linux Step 18

Step 2. Enter y to approve installation

Method 5 of 5: Ubuntu OpenJDK Method Using Console

Ubuntu no longer supports Oracle Java packages, but does support OpenJDK.

Install Java on Linux Step 19
Install Java on Linux Step 19

Step 1. Enter one of the commands below into your console program:

  • If you don't want to install the plugin in your browser: sudo apt-get install openjdk-6-jre.
  • If you want to install a plug-in in your browser: sudo apt-get install openjdk-6-jre icedtea6-plugin
  • If you are using a server without graphics and want a dedicated environment for running server applications (such as Tomcat or Glassfish): sudo apt-get install --no-install-recommends openjdk-6-jre-headless
  • If you need the full JDK (for writing Java programs): sudo apt-get install openjdk-6-jdk
  • apt-get can automatically handle existing dependencies and provide a list of changes for confirmation.
Install Java on Linux Step 20
Install Java on Linux Step 20

Step 2. Enter y to approve installation

Tips

  • Even if you're not familiar with the console method, it's easier to do than the GUI method.
  • If you find a guide on your distribution, we recommend using it because on some existing distributions, the software repository comes with Java (which is to your advantage).
  • It's easier to install from storage than to download it on the Oracle site.
  • Another tip for following through with the rpm installation process is to use 'rpm -ivv … ' which will fire up verbose output and give you a lot of information about the install at the time of the install process. You can do the same with any other rpm activity to get an explanation of the current activity.
  • On Linux Red Hat 8.0, launch the Nautilus file manager, open the directory, and click on the rpm file name that will initiate the installation process. However, this method no longer works on Fedora Core 4 (this has not been tried on any other FC version). In fact, if you do this, you will get a warning message telling you that the file name indicates that the file is not executable even if the contents of the file are of an "executable" type.

Recommended: