Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: HOWTO: Custom Installation of Sun Java

  1. #1
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Ubuntu 12.04 Precise Pangolin

    HOWTO: Custom Installation of Sun Java

    As a new forum member, I've seen quite a lot of threads asking how to install the latest Sun java JREs and JDKs. Sometimes instructions are given, other times not. The official help documentation doesn't really give instructions on installing Sun Java, without using the package from the package repositories.

    So I am writing this to provide a one-stop shop for those wanting to install Sun's JRE or JDK on Ubuntu. This how-to works with both 6.06 and 6.10 versions of Ubuntu, and with JRE 1.5.0_x and 1.6.0, and JDK 1.6 SE. It also assumes that you run 32-bit x86 architecture systems. Following these steps will accomplish:
    1. JRE installation into your /opt directory, and plugin installation for Firefox.
    2. JDK installation into your /opt for Java programming.
    3. Setting correct references in /usr/bin for command-line invocation of Java tools.


    Step One - initial download

    Download the linux binaries for Java from Sun's official Java website.
    http://www.java.sun.com

    Place the downloaded files in your home folder. For example: /home/samjh/

    Step Two - installing the JRE

    Open Nautilus (the default Gnome graphical file manager). Navigate to your downloaded JRE binary. Right-click on the file, select Properties. A properties dialog box will open up. Select the Permissions tab, and tick the box that says to allow the file to run as an executable. Click OK.

    Double-click on the downloaded JRE binary. A dialog box will appear, asking how to open it. Select "Run in Terminal" (do not just select "Run"). A terminal window will open with the license agreement. Keep pressing enter to scroll through the agreement (it takes several seconds if you hold it down). It will ask if you accept the agreement, so type "y" without quotation marks, and press enter.

    The file will unpack itself. When it finishes, close the terminal window if it doesn't close automatically.

    Step Three - moving the JRE directory to /opt

    Open your terminal.

    Navigate to the directory where the unpacked JRE folder is (the folder name should be jre1.5.0_x or jre1.6.0). If you followed the instructions above, this will be in /home/yourusername/

    Type this command (substitute yourjredirectoryname with the actual directory name):
    Code:
    sudo cp -r ./yourjredirectoryname /opt
    For example:
    sudo cp -r ./jre1.6.0 /opt

    It will ask for your password. Type it in and press enter, and the command will copy your JRE directory and its contents to the /opt directory.

    Step Four - create symbolic links in user binary directory

    Stay in your terminal window. Type the following command to navigate to usr/bin:
    Code:
    cd /usr/bin
    Then type these commands to remove existing java symbolic links (Do NOT type these all on the one line! Use separate lines for each!):
    Code:
    sudo rm ./java
    sudo rm ./java_vm
    sudo rm ./javaws
    Don't worry if it tells you the files cannot be found. Ignore them, because it just means that your existing Java installation didn't create the links.

    Then type these commands to add new symbolic links (substitute yourjredirectoryname with your actual JRE directory name):
    Code:
    sudo ln -s /opt/yourjredirectoryname/bin/java ./java
    sudo ln -s /opt/yourjredirectoryname/bin/javaws ./javaws
    sudo ln -s /opt/yourjredirectoryname/bin/java_vm ./java_vm
    For example:
    sudo ln -s /opt/jre1.6.0/bin/java ./java

    Step Five - create symbolic link to Java plugin for Firefox

    First, use Nautilus, and navigate to /opt/yourjredirectoryname/plugin/i386/ns7 directory. Right-click on the libjavaplugin_oji.so file, and select Properties, then select Permissions in the dialog window. Check to see that the owner of the file is you (it should say your user name).

    If it says the owner is root, then the plugin will not work for anyone other than root. You need to type this in terminal to get it to work for you:
    Code:
    sudo chmod 755 libjavaplugin_oji.so
    Now, use the cd command in your terminal to navigate to the /home/yourusername/.mozilla/plugins directory. Substitute yourusername with your actual user name, and take care to include the full-top (".") in .mozilla.
    For example:
    cd /home/samjh/.mozilla/plugins

    (If the plugins directory doesn't exist, then create one. Feisty Fawn users have reported that the plugin goes to /usr/lib/firefox/plugins instead, so please place your plugin link to that directory instead of the one I've specified.)

    Now, command your terminal with this proclamation:
    Code:
    ln -s /opt/yourjredirectoryname/plugin/i386/ns7/libjavaplugin_oji.so ./
    Close any existing Firefox sessions. Re-start Firefox.
    Go to http://www.java.com/en/download/installed.jsp and click on the "Verify Installation" button. The next page will check your installation for several seconds. If it then says "We detected your Java environment as follows", then your installation of the plugin was a success.

    Now go make love, have a shower, and return when well-rested. You have successfully installed the Java Runtime Environment.

    Step Six - install the JDK

    Repeat Steps Two and Three, but use your downloaded JDK binary instead of the JRE one.

    Step Seven - linking the JDK tools

    Similar to Step Four.

    Navigate to /usr/bin using your terminal, and type the following:
    Code:
    sudo ln -s /opt/yourjdkdirectoryname/bin/javac ./
    This will allow the javac command to be run without having to specify the path every time.

    Optionally you can also run this:
    Code:
    sudo ln -s /opt/yourjdkdirectoryname/bin/jar ./
    But Ubuntu already ships with fastjar already linked, which should be a good enough jar packer. So linking jar is entirely optional. I personally use fastjar.

    Now go make love, have a shower, and return when well-rested. You have successfully installed the Java Development Kit.

    Uninstalling JRE and/or JDK

    If you are uninstalling the JRE or JDK, you can do it using the terminal like this (where yourjavadirectoryname is the directory you want to remove):
    Code:
    cd /opt
    sudo rm -r ./yourjavadirectoryname
    Then navigate to /usr/bin, and do this for JRE...
    Code:
    cd /usr/bin
    sudo rm ./java
    sudo rm ./javaws
    sudo rm ./java_vm
    ...or this for JDK...
    Code:
    cd /usr/bin
    sudo rm ./javac
    sudo rm ./jar
    ...note that you won't need to remove the link for jar if you didn't make a link during installation.

    To remove the firefox plugin, do this:
    Code:
    cd /home/yourusername/.mozilla/plugins
    rm ./libjavaplugin_oji.so
    Done!

    Here endeth this newbie's guide to installing/uninstalling Sun Java, the non-packaged way.


    Rationale for installing separate JRE and JDK:
    I am a Java programmer. As such, I have occasionally need to use multiple JDK and even multiple JREs for compatibility testing. Separating your JRE and JDK installation will allow you to use separate Java build and test environments without affecting your ability to run Java software or applets. Also, the loss of the JDK will not equal losing JRE functionality, so you have more flexibility over your Java installation.



    DISCLAIMER: Your computer configuration may not be fully compatible with the instructions posted above. The instructions are provided as-is, without any warranty or promise, express or implied, against direct or indirect damages of any kind. Use these instructions at your own risk.
    Last edited by samjh; September 9th, 2008 at 10:13 AM. Reason: Lots of fixes from feedback! Thanks!

  2. #2
    Join Date
    Oct 2005
    Location
    Fribourg,Switzerland
    Beans
    1,749

    Re: HOWTO: Custom Installation of Sun Java

    Glad to see your HowTo's up there!
    my JAMENDO * The XY sex-determination system is the sex-determination system found in humans and Z was my donor! * Tarot and Poya Sutra | * # 12755

  3. #3
    Join Date
    Apr 2005
    Location
    Brick, NJ 08723
    Beans
    20
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: HOWTO: Custom Installation of Sun Java

    Personally, I've always preferred to install Java on Ubuntu using java-package.

    A quick HOWTO can be found here:

    http://wiki.serios.net/wiki/Ubuntu_J...K_installation

  4. #4
    Join Date
    Oct 2005
    Beans
    52

    Re: HOWTO: Custom Installation of Sun Java

    Thanks for the how to. It seems great for those of us who are pretty new to the ubuntu world. I have a very basic question - where are you finding the binaries for linux on sun's website? I am having trouble finding the jdk binary...maybe I am just blind or something.

  5. #5
    Join Date
    Mar 2006
    Beans
    95

    Re: HOWTO: Custom Installation of Sun Java

    Quote Originally Posted by andyanderso View Post
    Thanks for the how to. It seems great for those of us who are pretty new to the ubuntu world. I have a very basic question - where are you finding the binaries for linux on sun's website? I am having trouble finding the jdk binary...maybe I am just blind or something.
    http://java.sun.com/javase/downloads/index.jsp

    from there choose which ever one you need. then download the self-extracting linux bin. if you are only in need of the runtime environment then look for JRE on the page.

  6. #6
    Join Date
    Mar 2006
    Location
    Milwaukee, WI
    Beans
    23
    Distro
    Ubuntu 6.10 Edgy

    Re: HOWTO: Custom Installation of Sun Java

    Quote Originally Posted by samjh View Post
    Step Five - create symbolic link to Java plugin for Firefox

    First, use Nautilus, and navigate to /opt/yourjredirectoryname/plugin/i386/ns7 directory. Right-click on the libjavaplugin_oji.so file, and select Properties, then select Permissions in the dialog window. Check to see that the owner of the file is you (it should say your user name).

    If it says the owner is root, then your plugin will not work. You will need to reinstall the JRE again. This will sometimes occur, although I'm not quite sure why. It's a rare thing though, so don't fret.

    Now, use the cd command in your terminal to navigate to the /home/yourusername/.mozilla/plugins directory. Substitute yourusername with your actual user name, and take care to include the full-top (".") in .mozilla.
    For example:
    cd /home/samjh/.mozilla/plugins

    Now, command your terminal with this proclamation:
    Code:
    ln -s /opt/yourjredirectoryname/plugin/i386/ns7/libjavaplugin_oji.so ./
    Close any existing Firefox sessions. Re-start Firefox.
    Go to http://www.java.com/en/download/installed.jsp and click on the "Verify Installation" button. The next page will check your installation for several seconds. If it then says "We detected your Java environment as follows", then your installation of the plugin was a success.

    First off, thank you very much for a concise and well-written How-to. I appreciate the help.

    I have a problem with the step I quoted, though. I have no plugin directory under .mozilla in my home folder. If I remember correctly, I did a mass installation of a bunch of applications which set up my java plugin and now I'm unable to find the correct location. I run Firefox 2.0.

    Other than that, it looks like both the JRE and JDK are installed.

    Any ideas?

  7. #7
    Join Date
    Dec 2006
    Location
    Hungary, Bp
    Beans
    150
    Distro
    Ubuntu 6.06 Dapper

    Re: HOWTO: Custom Installation of Sun Java

    First, use Nautilus, and navigate to /opt/yourjredirectoryname/plugin/i386/ns7 directory. Right-click on the libjavaplugin_oji.so file, and select Properties, then select Permissions in the dialog window. Check to see that the owner of the file is you (it should say your user name).

    If it says the owner is root, then your plugin will not work. You will need to reinstall the JRE again. This will sometimes occur, although I'm not quite sure why. It's a rare thing though, so don't fret


    I have a problem with this. I reinstalled it, and it still says that the owner is root. Maybe I should just change the ownership(chown), and it will solve it?
    One ring to rule them all, one ring to find them;
    One ring to bring them all, and in the darkness bind them.

  8. #8
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: HOWTO: Custom Installation of Sun Java

    Nice How-to

    This thread has been added to the UDSF wiki.

    Custom_JAVA
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  9. #9
    Join Date
    Dec 2006
    Location
    Mississauga, ON, CA
    Beans
    463

    Re: HOWTO: Custom Installation of Sun Java

    Quote Originally Posted by dorcssa View Post
    First, use Nautilus, and navigate to /opt/yourjredirectoryname/plugin/i386/ns7 directory. Right-click on the libjavaplugin_oji.so file, and select Properties, then select Permissions in the dialog window. Check to see that the owner of the file is you (it should say your user name).

    If it says the owner is root, then your plugin will not work. You will need to reinstall the JRE again. This will sometimes occur, although I'm not quite sure why. It's a rare thing though, so don't fret


    I have a problem with this. I reinstalled it, and it still says that the owner is root. Maybe I should just change the ownership(chown), and it will solve it?

    Same problem here. Would the command bellow help?

    Code:
     sudo chmod 755 libjavaplugin_oji.so

    BTW, thanks for the tutorial !!!!


    Vic.

  10. #10
    Join Date
    Dec 2006
    Location
    Mississauga, ON, CA
    Beans
    463

    Re: HOWTO: Custom Installation of Sun Java

    Quote Originally Posted by victorbrca View Post
    Same problem here. Would the command bellow help?

    Code:
     sudo chmod 755 libjavaplugin_oji.so

    BTW, thanks for the tutorial !!!!


    Vic.
    This command has worked for me..... But don't take it from me, I'm just a noob...


    Vic.

Page 1 of 3 123 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
  •