• Increase font size
  • Default font size
  • Decrease font size

How to Install Java in Linux

 

Manual Non-RPM Method

This is the 'generic' variant that also works with GNU/Linux clones that do not support RPM. It does not require administrator rights and allows to install multiple java versions on the same computer.

  1. 1
    Download the JDK from Sun[1].

    Ads by Google

    Professional Linux Laptop

     Linux on M6400, E6500, E6400, E4200 Fedora, Ubuntu, RHEL, Debian, Slack
    www.EmperorLinux.com
     
  2. 2
    Click on the "Download" link in the JDK 6 section.
     
  3. 3
    Accept the license and continue.
     
  4. 4
    Under the "Linux Platform", select "self-extracting file".
     
  5. 5
    Download this .bin file and save it to your GNU/Linux machine.
     
  6. 6
    Once it has been downloaded, switch to the directory where you saved the file. You do not need to be a root and only must have the write access to the folder where you wish to install java. If your administrator is not supportive, you may need to place java into your home folder or even better on some shared network location.
     
  7. 7
    Type sh name_of_the_downloaded_file, for instance sh jdk-6u2-linux-i586.bin. There is no need to make this file executable.
     
  8. 8
    The license agreement should start appear on the screen. Scroll to the end of it with 'Enter' and type yes.
     
  9. 9
    This installer will create its installation in the same folder, where the downloaded file was placed and from where you have started the installation script. But the installed java jre is rather independent and can be easily moved into another place just by copying all its files.
     
  10. 10
    You can install multiple different jre's this way: they coexist together and can be used if some software requires the older version to run.
     
  11. 11
    The java executable you need to launch is located in a subfolder, called 'bin'. This way of installation will not configure a default 'java' command for you: you must do this manually or always include the full path in your startup script.
     

Manual RPM Method

This seems a 'more civilized' way to install java: it allows the installer to check the dependencies on some system libraries that may be missing. However it does not support versioning easily and may fail even in some systems that do support RPMs. The current java installations are rather self-dependent and the required minimal requirements are usually satisfied anyway.

  1. 1
    Download the JDK from Sun[2].
     
  2. 2
    Click on the "Download" link in the JDK 6 section.
     
  3. 3
    Accept the license and continue.
     
  4. 4
    Under the "Linux Platform", select "RPM in self-extracting file".
     
  5. 5
    Download this .bin file and save it to your GNU/Linux machine.
     
  6. 6
    Once it has been downloaded, login as root and switch to the directory where you saved the file.
     
  7. 7
    Execute './filename', where filename is the name of the file that you downloaded. The filename might be very similar to jdk-6-linux-i586-rpm.bin depending on what the latest version is. You may have to make the file executable by executing the 'chmod +x filename.bin' command.
     
  8. 8
    You will get a license, press space bar a bunch of times until you are prompted to enter yes or no. Type in yes and hit enter.
     
  9. 9
    This will place an .rpm file in the same directory as your .bin file with the same name (minus the .bin part).
     
  10. 10
    Install the rpm file by executing 'rpm -i filename.rpm', where filename is the name of your .rpm file. (Such as jdk-6-linux-i586.rpm).
     
  11. 11
    Now, if you want to be able to execute this version of Java interpretor or compiler from any directory on your GNU/Linux system you will have to create a few symbolic links:
    • ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
       
    • ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac
       
     
  12. 12
    You are done!
     

Ubuntu Method Using a GUI Package Manager

  1. 1
    Open a package manager (probably either Synaptic or Adept Manager)
     
  2. 2
    Perform a search for sun-java6.
     
  3. 3
    Select sun-java6-bin and sun-java6-jre for installation. If you want to use Java as a plug-in in your browser, then also select to install sun-java6-plugin. Depending on the package manager, you may be asked if you wish to install the required dependencies or it will automatically select them without confirmation.
     
  4. 4
    Click the button to apply the changes. Depending on the package manager, a pop-up window may appear asking for you to confirm the changes.
     
  5. 5
    Wait while it downloads and installs. Partway through the process, a window will appear asking you to accept Sun's license for using Java; read and accept the license.
     
  6. 6
    Java should now be installed and ready to use!
     

Ubuntu Method Using a Console

  1. 1
    Enter one of the following into your console program: sudo apt-get install sun-java6-bin sun-java6-jre if you don't want the browser plug-in or sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-plugin if you do need the plug-in. It automatically takes care of the dependencies and lists the changes for confirmation.
     
  2. 2
    Enter y to confirm the install.
     
  3. 3
    Accept the license that pops up after a short while.
     
  4. 4
    Java is now ready!
  5. http://www.wikihow.com/Install-Java-on-Linux
 

Add comment


Security code
Refresh