Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: [Tutorial] Manually installing the JDK 6 Update 13

  1. #1
    Join Date
    Mar 2009
    Location
    United Kingdom
    Beans
    302
    Distro
    Kubuntu

    [Tutorial] Manually installing the JDK 6 Update 13

    [Tutorial] Manually installing the JDK 6 Update 13


    1) Introduction

    This tutorial is meant to help someone install the latest version of the JDK, currently the JDK 6 Update 13. Included in the tutorial is the installation of the JDK itself, as well as installation of the included JRE and Java Web Plugin for Firefox. The instructions may work for other versions of the JDK. Please use your own discretion when deciding whether to use this tutorial with other versions of the JDK. It should be noted that this tutorial also deals with the installation of the new 64 bit Java Web Plugin.

    Also please note that this tutorial is meant to be very user friendly. If you are an advanced user you should be able to skim through in five minutes and get everything working.

    If you have anything to add please post away.

    2) Uninstallation of the current JDK/JRE/Web Plugin

    2.1)Uninstallation of the current Sun JDK/JRE/Web Plugin

    If you have the currently have the Sun JDK installed you need to remove it. Use the following command in the terminal:

    Note: If you are currently using some or all of these packages please note down which ones so you can revert if need be.

    Code:
    sudo apt-get remove sun-java6-jre sun-java6-jdk sun-java6-bin
    If you installed the Sun Java Web Plugin and made it default you will have to remove it as well using the terminal command:

    Note: If you are currently using this package please note it down so you can revert if need be.

    Code:
    sudo apt-get remove sun-java6-plugin

    Note: If you made the Sun Java Web Plugin default you will either have to make the IcedTea Java Web Plugin default (not covered here) or make the new Sun Java Web Plugin default (covered in the optional section "Setting up the Java Web Plugin").


    2.2) (Optional) Uninstallation of the OpenJDK/JRE/IcedTea Web Plugin


    By default Ubuntu comes with the OpenJDK JRE, IcedTea Java Web Plugin and a few other dependant packages. If you leave these packages and do not complete any of the optional sections these packages will still be used by default in everything but the terminal. However, if you are like me and do not want multiple versions of Java lying around taking up hard disk space then you can remove them using the following terminal command:

    Note: You will not necessarily have all these packages installed. If you are missing some please note down which ones so you can revert properly if need be.

    Code:
    sudo apt-get remove openjdk-6-jre openjdk-6-jre-headless icedtea-6-jre-cacao icedtea6-plugin default-jre default-jre-headless icedtea-gcjwebplugin

    2.3) Removal of unnecessary packages


    Everything should have been uninstalled correctly. However, to make sure we do not have any additional unused packages around that we no longer need, type the following in the terminal:

    Code:
    sudo apt-get autoremove

    3) Download of the correct JDK bin file


    Go to http://java.sun.com/javase/downloads/index.jsp in your browser. On this page the current JREs and JDKs are listed along with some other tools. This tutorial was built for the the JDK 6 Update 13. However, it will probably work for newer/older updates of the 6 series as well. If there is a newer JDK available you may want to grab it and adapt the tutorial.

    After choosing the appropriate JDK click on the download link next to it. If you use i386 (32 bit) Ubuntu you will want to download the “Linux” version on the next page, however if you are on amd64 (64 bit) Ubuntu you will want to download the “Linux x64” version.

    Once the JDK file (jdk<something>.bin) has finished downloading you need to move it to your home directory.

    4) Extract and install the bin file

    Open a terminal and type the following commands:

    Code:
    chmod +x jdk*.bin
    sudo ./jdk*.bin
    Before the bin file will extract you have to agree to the terms and conditions (by typing yes or no). To skip through the agreement simply press q.

    Now you have an extracted JDK directory (with root ownership) in your home directory. Now we need to move it to somewhere a little more appropriate. I moved mine to /usr/local/. If you are an advanced user you can pretty much put in anywhere you want. Just make sure you adapt the tutorial accordingly.

    At this point please note down the name of the JDK folder in your home folder, you will need to type it in for later commands. For me the name of the folder is :

    Code:
    jdk1.6.0_13
    Henceforth the folder will be refered to as <JAVA_FOLDER>. If you see <JAVA_FOLDER> in any of the commands replace it with the folder name.

    To move the JDK folder to /usr/local/ type the following in the terminal.

    Code:
    sudo mv <JAVA_FOLDER>/ /usr/local/
    5) Setting up the JAVA_HOME and PATH variables

    In order to use the various Java terminal commands (such as java & javac) with the JDK that we just installed the JAVA_HOME and PATH variables need to be set. This involves editing a text file, however, you have to edit a different text file depending on whether you want to set up the variables system wide or just for an individual user.

    Please note down which file you edited in case the settings need to be removed.

    5.1) Settings the variables up system wide

    To set the variables up system wide either the /etc/profile file or the /etc/bash.bashrc need to be edited. The difference between these files is that the former is loaded once when you log in, whereas the latter is loaded every time time you start a new terminal.

    Please be careful when adding the PATH line. If you execute the command without the $PATH: part then your terminal will stop working properly.

    To edit the /etc/profile file type the following in the terminal:

    Code:
     
    sudo -i
    echo "export JAVA_HOME=/usr/local/<JAVA_FOLDER>/bin/java" >> /etc/profile
    echo "export PATH=$PATH:/usr/local/<JAVA_FOLDER>/bin" >> /etc/profile
    exit
    Note: It is important to type exit here.

    Alternatively, to edit the /etc/bash.bashrc file type the following in the terminal:

    Code:
     
    sudo -i
    echo "export JAVA_HOME=/usr/local/<JAVA_FOLDER>/bin/java" >> /etc/bash.bashrc
    echo "export PATH=$PATH:/usr/local/<JAVA_FOLDER>/bin" >> /etc/bash.bashrc
    exit
    Note: It is important to type exit here.

    If you accidentally added an incorrect PATH variable press alt+f2, type: gksudo nautilus, navigate to the /etc directory and remove the offending line (at the bottom of the file) using a text editor.

    5.2 Settings the variables up for a single user

    To set the variables for a single user the $HOME/.profile file or $HOME/.bashrc file need to be edited. The difference between these files is that the former is loaded once when you log in, whereas the latter is loaded every time time you start a new terminal.

    To edit the $HOME/.profile file type the following in the terminal:

    Code:
     
    echo "export JAVA_HOME=/usr/local/<JAVA_FOLDER>/bin/java" >> $HOME/.profile
    echo "export PATH=$PATH:/usr/local/<JAVA_FOLDER>/bin" >> $HOME/.profile
    Alternatively, to edit the $HOME/.bashrc file type the following in the terminal:

    Code:
     
    echo "export JAVA_HOME=/usr/local/<JAVA_FOLDER>/bin/java" >> $HOME/.bashrc
    echo "export PATH=$PATH:/usr/local/<JAVA_FOLDER>/bin" >> $HOME/.bashrc
    If you accidentally added an incorrect PATH variable open your home folder, press ctrl.h and remove the offending lines (at the bottom of the file) using a text editor.

    5.3) Testing the changes

    Depending on the file that you edited you will either have to start a new terminal or log in and out for the changes to take effect. Once you have either logged in and out or started a new terminal test the java commands that you use to see if they are working. If they are not something has gone wrong with the installation.

    5.4) A point of interest

    If you complete the (optional) section "Setting up the default JRE" this section may not actually be necessary for use of the java command. However, it is necessary for any other commands you want to use, such as javac.

    6) (Optional) Setting up the default JRE

    If you decided to remove the default JRE (OpenJDK JRE) this section is necessary for Java applications to run correctly. However, if you want to keep the OpenJDK as default do not do this section.

    To set up the new JRE as default type the following in the terminal:

    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/<JAVA_FOLDER>/jre/bin/java" 1
    sudo update-alternatives --set java /usr/local/<JAVA_FOLDER>/jre/bin/java

    7) (Optional) Setting up the Java Web Plugin


    If you removed the OpenJDK JRE and the IcedTea Java Web Plugin you need to complete this section for Java applets to work in your browser. However, if you left the OpenJDK JRE and IcedTea Java Web Plugin you may want to skip this section.


    The commands are different for the i386 and amd64 architectures. Please follow the 32 bit section if you have Ubuntu i386 and the 64 bit version if you have Ubuntu amd64.

    Just in case the following does not work please write down the original settings in the about:config section.

    7.1) 32 bit

    Code:
    sudo mkdir /usr/lib/mozilla/plugins
    sudo ln -s /usr/local/<JAVA_FOLDER>/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/
    Now restart Firefox, Open Tools > Add-ons > Plugins and enable libjavaplugin_oji. If you are still having problems with Java applets complete the following steps:

    Type the following into the Firefox URL input box:

    Code:
    about:config
    Next click agree. In the search box at the top on the next page type in java. Somewhere in this list is an entry for java.java_plugin_library_name. You must change this to:

    Code:
    libjavaplugin_oji
    In the same list there is an entry for java.default_java_location_others. You must change this to:

    Code:
    /usr/local/<JAVA_FOLDER>/jre/
    7.2) 64 bit

    Code:
    sudo mkdir /usr/lib/mozilla/plugins
    sudo ln -s /usr/local/<JAVA_FOLDER>/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/
    Now restart Firefox, Open Tools > Add-ons > Plugins and enable libnpjp2. If you are still having problems with Java applets complete the following steps:

    Type the following into the Firefox URL input box:

    Code:
    about:config
    Next click agree. In the search box at the top on the next page type in java. Somewhere in this list is an entry for java.java_plugin_library_name. You must change this to:

    Code:
    libnpjp2
    In the same list there is an entry for java.default_java_location_others. You must change this to:

    Code:
    /usr/local/<JAVA_FOLDER>/jre/
    8) Reversion

    In order to revert to the please follow the following steps.

    8.1) Uninstallation of the new Sun JDK

    To remove the folder for the new Java Sun JDK you need to type the following in the terminal:

    Code:
    sudo rm -r /usr/local/<JAVA_FOLDER>/
    8.2) Removal of the PATH and JAVA_HOME variables

    You now need to remove the settings from the file you edited when you set these variables. If you edited one of the files in your home folder you need to do the following:

    Open the home folder in the file browser, press ctrl.h (reveal hidden files) and open the correct file in a text editor. Then remove the lines that you added (down the bottom of the file).

    If you edited one of the files in the /etc directory you need to press alt+f2, type gksudo nautilus and press enter. Now navigate to the /etc directory, open the correct file in a text editor and remove the lines that you added.

    8.3) Install the previous versions of the JDK/JRE/Web Plugin

    To install the versions of the JDK/JRE/Web Plugin that you had before you need to complete the section "2) Uninstallation of the current JDK/JRE/Web Plugin" in reverse. Rather than typing:

    Code:
    sudo apt-get remove <package1> <package2>...
    In the terminal. You need to type:

    Code:
    sudo apt-get install <package1> <package2>...
    Please do not simply copy and paste the commands from the uninstallation section and change remove to install. If you remember I said note down the packages that you actually had installed in that section. Please only install the packages that you actually had before.

    8.4) (Optional) Set up the previous JRE as default

    If you set up the new Sun Java JRE as default you will need to complete this step to revert.

    To complete this step type the following in the terminal:

    Code:
    sudo update-alternatives --config java
    You will now see a list of options for JREs to use. You need to choose the option that maps to the previous version of the JRE you were using (likely to be the OpenJDK).

    8.5) (Optional) Set up the previous Java Web Plugin

    If you set up the new Sun Java Web Plugin you will need to complete this step to revert.

    If you are using 32 bit Ubuntu type the following in the terminal:

    Code:
    sudo rm /usr/lib/mozilla/plugins/libjavaplugin_oji.so
    If you are using 64 bit Ubuntu type the following in the terminal:

    Code:
    sudo rm /usr/lib/mozilla/plugins/libnpjp2.so
    If you had to set up any of the settings in the about:config section (you should have noted the originals down) please change these back to the originals.
    Last edited by James_Lochhead; April 2nd, 2009 at 10:48 AM.

  2. #2
    Join Date
    Mar 2009
    Location
    United Kingdom
    Beans
    302
    Distro
    Kubuntu

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    This is an updated version of the tutorial I posted yesterday.

  3. #3
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    it's a decent tut but be careful in case you want to revert.
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  4. #4
    Join Date
    Mar 2009
    Location
    United Kingdom
    Beans
    302
    Distro
    Kubuntu

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Updated with a section on how to revert.

  5. #5
    Join Date
    Mar 2009
    Location
    United Kingdom
    Beans
    302
    Distro
    Kubuntu

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Just updated to Jaunty. Update 13 is installed by default. This tutorial should be applicable to future releases of the 6 series though.

  6. #6
    Join Date
    Sep 2006
    Beans
    3,170
    Distro
    Ubuntu Karmic Koala (testing)

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Excellent howto, jaunty comes with latest but works great on my intrepid box.

  7. #7
    Join Date
    Feb 2007
    Beans
    10

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Thanks James,

    You saved me some time looking up the system wide variables. I just setup a simple server and wanted to have Java without all the baggage installing it through the repos brings. I didn't want to install X11, or any other junk, just Java.

    Your timing couldn't have been better.

    Wicked

  8. #8
    Join Date
    Jan 2009
    Location
    Bay Area CA
    Beans
    87
    Distro
    Ubuntu Development Release

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Thank you very much for the knowledge.

    However, as a Linux beginner, those step by step instructions are VERY intimidating.

    The biggest obstacle to total linux conversion: software installation, which is far easier to do in Windows.

    Dont get me wrong...I finally mastered joining video files in Linux - without having to jump to Shitsa.

    I'm slowly evolving to the Linux world...

    When is Jaunty Jackolope gonna be released?

  9. #9
    Join Date
    Mar 2009
    Location
    United Kingdom
    Beans
    302
    Distro
    Kubuntu

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    It is not really a process for a beginner, although I tried to make it as easy as possible. Jaunty will be released on the 23rd so there is hardly much point doing this process now if you are planning to upgrade.

  10. #10
    Join Date
    Jan 2009
    Location
    Bay Area CA
    Beans
    87
    Distro
    Ubuntu Development Release

    Re: [Tutorial] Manually installing the JDK 6 Update 13

    Quote Originally Posted by James_Lochhead View Post
    It is not really a process for a beginner, although I tried to make it as easy as possible. Jaunty will be released on the 23rd so there is hardly much point doing this process now if you are planning to upgrade.
    Thanks for replying.

    Dont wanna derail the thread but is Jaunty a significant upgrade or just a sequel?

    Peace

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •