Wednesday, 16 May 2012

How do I download and install Java for my Linux computer?

How do I download and install Java for my Linux computer?


This article applies to:
  • Platform(s): Red Hat Linux, SUSE Linux, Oracle Linux, Oracle Enterprise Linux, SLES
  • Java version(s): 6.0, 7.0

Linux System Requirements
See supported System Configurations for information about supported platforms, operating systems, desktop managers, and browsers.
You will also need a Pentium 166MHz or faster processor with a minimum of 75MB free disk space and a minimum of 64MB of RAM.

Note: For downloading Java other flavors of Linux see Java for Ubuntu, Java for Fedora


Follow these steps to download and install Java for Linux.
  1. Download
  2. Install
  3. Enable and Configure
Download
  1. Go to http://java.com and click on the Download button
  2. There are two types of installation packages.
    • Linux self extracting binary file
      This file can be used to install Java in a location chosen by the user and can be installed by anyone (not only root users). As long as you are not root user, it cannot displace the system version of the Java platform suppled by Linux.
    • Linux RPM package
      Linux RPM (Redhat Package Manager) uses RPM to install Java. In order to use this method, you need to have RPM available on your system. Otherwise use the other option.

    Download the package that best suits your needs. You can download the file to any of the directories on your system.
  3. Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle.
    • Before you download the file, notice its byte size provided on the download page on the web site.
    • Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.



Install
Note: The instructions below are for installing Java 7. If you are installing another version, make sure you change the version number appropriately when you type the commands at the terminal.
Example: For Java 6 replace 7u with 6u.

Linux self-extracting
Follow these instructions:
  1. Change the permission of the file you downloaded to be executable. Type:
    chmod a+x jre-7u<version>-linux-i586.bin
    where <version> is to be replaced by the version downloaded.
    Example: For jre-7u3, the command is
    chmod a+x jre-7u3-linux-i586.bin
  2. Verify that you have permission to execute the file. Type:
    ls -l
Make sure the installation file has executable permission

  1. Change to the directory in which you want to install. Type:
    cd <directory path name>
    For example, to install the software in the /usr/java/ directory, Type:
    cd /usr/java/

    Note about root access: To install Java in a system-wide location such as /usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install the Java in your home directory or a subdirectory for which you have write permissions.
  1. Run the self-extracting binary Type:
    ./jre-7u<version>-linux-i586.bin

    The license agreement is displayed. Review the agreement. Press the spacebar to display the next page. At the end, enter yes to proceed with the installation.
  2. Java is installed into its own directory. In this example, it is installed in the /usr/java/jre1.7.0_<version> directory. When the installation has completed, you will see the word Done.
The installation completes

  1. Verify that the jre1.7.0_<version> sub-directory is listed under the current directory. Type:
    ls
Verify the installation filename

The installation is now complete. Skip to the Enable and Configure section.


Linux RPM
Follow these instructions:
  1. Login as Super user
  2. Change to the directory in which you want to install. Type:
    cd <directory>
    For example, to install the software in the /usr/java/ directory, Type:
    cd /usr/java

    Note about root access: To install Java in a system-wide location such as/usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install Java in your home directory or a subdirectory for which you have write permissions.
  3. Change the permission of the file you downloaded to be executable. Type:
    chmod a+x jre-7u<version>-linux-i586-rpm.bin
    where <version> is to be replaced by the version downloaded.
    For Example: To install jre-7u3, above command will become
    chmod a+x jre-7u3-linux-i586-rpm.bin
  4. Start the installation process. Type:
    ./jre-7u<version>-linux-i586-rpm.bin

    The license agreement is displayed. Review the agreement. Press the spacebar to display the next page. At the end, enter yes to proceed with the installation.
  5. The installation file creates and runs the file jre-7<version>-linux-i586.rpm in the current directory.
RPM unpacking completes
  1. Verify that the jre1.7.0_<version> sub-directory is listed under the current directory. Type:
    ls
Verify the installation filename

The installation is now complete. Go to the Enable and Configure section.

Enable and Configure
Firefox or Mozilla
To configure the Java Plugin follow these steps:
  1. Exit Firefox browser if it is already running.
  2. Uninstall any previous installations of Java Plugin.
    Only one Java Plugin can be used at a time. When you want to use a different plugin, or version of a plugin, remove the symbolic links to any other versions and create a fresh symbolic link to the new one.
  3. Create a symbolic link to the libnpjp2.so file in the browser plugins directory
    • Go to the plugins sub-directory under the Firefox installation directory
      cd <Firefox installation directory>/plugins
    • Create the symbolic link
      ln -s <Java installation directory>/lib/i386/libnpjp2.so

    Note: If you are upgrading your Java version then before creating new symbolic link you should remove old symbolic link to enable latest downloaded Java.

    To remove old symbolic link:
    type cd <Firefox installation directory>/plugins
    rm libjavaplugin_oji.so

    Example
    • If Firefox is installed at this directory:
      /usr/lib/<Firefox installation directory>
    • And if the Java is installed at this directory:
      /usr/java/<Java installation directory>
    • Then type in the terminal window to go to the browser plug-in directory:
      /usr/lib/<Firefox installation directory>/plugin
    • Enter the following command to create a symbolic link to the Java Plug-in for the Mozilla browser.
      ln -s /usr/java/<Java installation directory>/lib/i386/libnpjp2.so


  4. Start the Firefox browser, or restart it if it is already up.

    In Firefox, type about:plugins in the Location bar to confirm that the Java Plugin is loaded. You can also click the Tools menu to confirm that Java Console is there.

Test Installation
To test that Java is installed and working properly on your computer, run this test applet.

How do I download and install Java for my Linux computer?


This article applies to:
  • Platform(s): Red Hat Linux, SUSE Linux, Oracle Linux, Oracle Enterprise Linux, SLES
  • Java version(s): 6.0, 7.0

Linux System Requirements
See supported System Configurations for information about supported platforms, operating systems, desktop managers, and browsers.
You will also need a Pentium 166MHz or faster processor with a minimum of 75MB free disk space and a minimum of 64MB of RAM.

Note: For downloading Java other flavors of Linux see Java for Ubuntu, Java for Fedora


Follow these steps to download and install Java for Linux.
  1. Download
  2. Install
  3. Enable and Configure
Download
  1. Go to http://java.com and click on the Download button
  2. There are two types of installation packages.
    • Linux self extracting binary file
      This file can be used to install Java in a location chosen by the user and can be installed by anyone (not only root users). As long as you are not root user, it cannot displace the system version of the Java platform suppled by Linux.
    • Linux RPM package
      Linux RPM (Redhat Package Manager) uses RPM to install Java. In order to use this method, you need to have RPM available on your system. Otherwise use the other option.

    Download the package that best suits your needs. You can download the file to any of the directories on your system.
  3. Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle.
    • Before you download the file, notice its byte size provided on the download page on the web site.
    • Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.



Install
Note: The instructions below are for installing Java 7. If you are installing another version, make sure you change the version number appropriately when you type the commands at the terminal.
Example: For Java 6 replace 7u with 6u.

Linux self-extracting
Follow these instructions:
  1. Change the permission of the file you downloaded to be executable. Type:
    chmod a+x jre-7u<version>-linux-i586.bin
    where <version> is to be replaced by the version downloaded.
    Example: For jre-7u3, the command is
    chmod a+x jre-7u3-linux-i586.bin
  2. Verify that you have permission to execute the file. Type:
    ls -l
Make sure the installation file has executable permission

  1. Change to the directory in which you want to install. Type:
    cd <directory path name>
    For example, to install the software in the /usr/java/ directory, Type:
    cd /usr/java/

    Note about root access: To install Java in a system-wide location such as /usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install the Java in your home directory or a subdirectory for which you have write permissions.
  1. Run the self-extracting binary Type:
    ./jre-7u<version>-linux-i586.bin

    The license agreement is displayed. Review the agreement. Press the spacebar to display the next page. At the end, enter yes to proceed with the installation.
  2. Java is installed into its own directory. In this example, it is installed in the /usr/java/jre1.7.0_<version> directory. When the installation has completed, you will see the word Done.
The installation completes

  1. Verify that the jre1.7.0_<version> sub-directory is listed under the current directory. Type:
    ls
Verify the installation filename

The installation is now complete. Skip to the Enable and Configure section.


Linux RPM
Follow these instructions:
  1. Login as Super user
  2. Change to the directory in which you want to install. Type:
    cd <directory>
    For example, to install the software in the /usr/java/ directory, Type:
    cd /usr/java

    Note about root access: To install Java in a system-wide location such as/usr/local, you must login as the root user to gain the necessary permissions. If you do not have root access, install Java in your home directory or a subdirectory for which you have write permissions.
  3. Change the permission of the file you downloaded to be executable. Type:
    chmod a+x jre-7u<version>-linux-i586-rpm.bin
    where <version> is to be replaced by the version downloaded.
    For Example: To install jre-7u3, above command will become
    chmod a+x jre-7u3-linux-i586-rpm.bin
  4. Start the installation process. Type:
    ./jre-7u<version>-linux-i586-rpm.bin

    The license agreement is displayed. Review the agreement. Press the spacebar to display the next page. At the end, enter yes to proceed with the installation.
  5. The installation file creates and runs the file jre-7<version>-linux-i586.rpm in the current directory.
RPM unpacking completes
  1. Verify that the jre1.7.0_<version> sub-directory is listed under the current directory. Type:
    ls
Verify the installation filename

The installation is now complete. Go to the Enable and Configure section.

Enable and Configure
Firefox or Mozilla
To configure the Java Plugin follow these steps:
  1. Exit Firefox browser if it is already running.
  2. Uninstall any previous installations of Java Plugin.
    Only one Java Plugin can be used at a time. When you want to use a different plugin, or version of a plugin, remove the symbolic links to any other versions and create a fresh symbolic link to the new one.
  3. Create a symbolic link to the libnpjp2.so file in the browser plugins directory
    • Go to the plugins sub-directory under the Firefox installation directory
      cd <Firefox installation directory>/plugins
    • Create the symbolic link
      ln -s <Java installation directory>/lib/i386/libnpjp2.so

    Note: If you are upgrading your Java version then before creating new symbolic link you should remove old symbolic link to enable latest downloaded Java.

    To remove old symbolic link:
    type cd <Firefox installation directory>/plugins
    rm libjavaplugin_oji.so

    Example
    • If Firefox is installed at this directory:
      /usr/lib/<Firefox installation directory>
    • And if the Java is installed at this directory:
      /usr/java/<Java installation directory>
    • Then type in the terminal window to go to the browser plug-in directory:
      /usr/lib/<Firefox installation directory>/plugin
    • Enter the following command to create a symbolic link to the Java Plug-in for the Mozilla browser.
      ln -s /usr/java/<Java installation directory>/lib/i386/libnpjp2.so


  4. Start the Firefox browser, or restart it if it is already up.

    In Firefox, type about:plugins in the Location bar to confirm that the Java Plugin is loaded. You can also click the Tools menu to confirm that Java Console is there.

Test Installation
To test that Java is installed and working properly on your computer, run this test applet.

2 comments: