View Poll Results: Was this guide helpful?

Voters
15. You may not vote on this poll
  • Yes

    13 86.67%
  • No

    2 13.33%
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Yet Another Way to Install Java 6

  1. #1
    Join Date
    Feb 2006
    Beans
    15

    Yet Another Way to Install Java 6

    There are so many guides to install Java 6 manually on the Ubuntu forums that I kinda got lost between them all (but I did get Java 6 working). I'm writing this guide in order to make it simple to install and easy to understand (through the shell script).

    Note: There are 2 ways to install java6 nowadays b/c java6 has been added to the repositories (multiverse)

    The following method is if you have the multiverse repository enabled/added to your /etc/apt/sources.list (I won't go covering how to do that here)

    To install:
    Code:
    sudo apt-get update
    # To install the mozilla plugin remove the # on the next line
    sudo apt-get install sun-java6-jdk #sun-java6-plugin
    update-java-alternatives --list
    # The line above should produce output somewhat similar to:
    # java-6-sun 63 /usr/lib/jvm/java-6-sun
    # Add the first part of the line above to the end of the next line
    sudo update-java-alternatives --set java-6-sun
    Now if you want to change java versions just do:
    Code:
    update-java-alternatives --list
    sudo update-java-alternatives --set <one of the java versions>
    ----------------------------------------------------------------------------------------------------------------------------

    The following method shows how to install java 6 manually (in case you don't want multiverse repo. enabled for security reasons or if you just want to learn how to do it)

    1. Download the Java 6 SDK (Make sure you download the "Linux self-extracting file") from http://java.sun.com/javase/downloads/index.jsp
    2. After it has finished downloading you will have a file called jdk-6-linux-i586.bin
    3. Run the following in the directory that the file is located in (Change any variables as you see fit)
    Code:
    JDKFILE=jdk-6-linux-i586.bin
    JDKFOLDER=jdk1.6.0
    JDKPATH=/opt
    
    chmod +x $JDKFILE
    sh $JDKFILE
    sudo mv $JDKFOLDER $JDKPATH
    
    # Uncomment the following line to have Mozilla browsers (i.e. Firefox) load the Java 6 plugin
    # ln -s $JDKPATH/$JDKFOLDER/jre/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins
    
    echo "export JAVA_HOME=$JDKPATH/$JDKFOLDER" >> ~/.bashrc
    echo "PATH=\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin:\$PATH" >> ~/.bashrc
    
    source ~/.bashrc
    Now you can test to see if java 6 is installed by running: `java -version` and `javac -version`
    This should print out something similar to:
    Code:
    joncfoo@A3200:~$ java -version
    java version "1.6.0"
    Java(TM) SE Runtime Environment (build 1.6.0-b105)
    Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
    
    joncfoo@A3200:~$ javac -version
    javac 1.6.0

    Now if you have other versions of Java installed and want to use them, the easiest way to do is would be to change the JAVA_HOME variable by doing:
    Code:
    export JAVA_HOME=/another/java/directory
    After you have done this, just launch whatever application(s) you need under that version of Java


    I hope this is straightforward and to the point. If not feel free to ask me any questions.
    Last edited by jonathan_c; February 23rd, 2007 at 05:35 PM.

  2. #2
    Join Date
    Apr 2006
    Beans
    5

    Wink Simply understandable! too comprehensive guide. Thank you!

    Simply understandable! too comprehensive guide. Thank you!

  3. #3
    Join Date
    Feb 2006
    Beans
    1,086
    Distro
    Ubuntu Gnome

    Re: Yet Another Way to Install Java 6

    Isn't it easier to add the edgy-backports repository to your sources.list and install the sun-java6 packages?

  4. #4
    Join Date
    Feb 2006
    Beans
    15

    Re: Yet Another Way to Install Java 6

    I did an `apt-cache search java6` right after I saw your post. You're right, it is in the repository. It wasn't there 2 days ago though

    Thanks!

  5. #5
    Join Date
    Aug 2006
    Beans
    1,225

    Re: Yet Another Way to Install Java 6

    Installing Java 6 from the backports is an unworkable method if you need multiple instances, or need to capture the latest updates from SUN as soon as possible. Besides, the package is prepared by a third party using the .bin file from SUN anyway. You suffer any security breaches inherent in the .bin file plus any included in the packaging script - thus explains its placement in backports.

    In addition, using the package isn't an option if you need an older version. The backports option is easy, but it isn't easier than just installing the .bin file by yourself. Food for thought.

  6. #6
    Join Date
    Oct 2006
    Location
    third planet from the sun
    Beans
    473
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Yet Another Way to Install Java 6

    sudo apt-get update
    # To install the mozilla plugin remove the # on the next line
    sudo apt-get install sun-java6-jdk #sun-java6-plugin
    update-java-alternatives --list
    sudo update-java-alternatives --set <java version from the command above>
    ok the original dummy here
    i would just enter this in the terminal


    sudo apt-get update
    # To install the mozilla plugin remove the # on the next line
    sudo apt-get install sun-java6-jdk sun-java6-plugin
    update-java-alternatives --list
    sudo update-java-alternatives --set sun-java6-jdk

    that is after making the changes you show in the comments, and think i did it right?

    i have a older sun java on here and i have read about not uninstalling or overwriting the old with a new???

    thanks for any help confimrming that is the right command
    i have the older version working and don't want to blow out java as i need it

  7. #7
    Join Date
    Feb 2006
    Beans
    15

    Re: Yet Another Way to Install Java 6

    the.phantom,
    If you used apt-get to install the new java6 then it shouldn't overwrite any other java versions. All the older versions should still be installed along-side the new version.

    On my machine `update-java-alternatives --list` produces:
    Code:
    joncfoo@A3200:~$ update-java-alternatives --list
    java-6-sun 63 /usr/lib/jvm/java-6-sun
    Running `sudo update-java-alternatives --set java-6-sun` would be the correct command for me to run.

    If by chance the output on your `update-java-alternatives --list` shows "sun-java6-jdk <some number> <path to sun-java6-jdk>" then it is perfectly ok for you to run `sudo update-java-alternatives --set sun-java6-jdk`

  8. #8
    Join Date
    Apr 2006
    Location
    Ontario, Canada
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Yet Another Way to Install Java 6

    Wow this is awesome! Works like a charm.

    Thanks!

  9. #9
    Join Date
    Feb 2008
    Beans
    1

    Re: Yet Another Way to Install Java 6

    If you have or prefer, as I do, to manually install the latest from Sun and you have followed the manual installation instructions above, then you can update your system alternatives as such:

    (I'm assuming you've moved the jdk directory to /opt)

    Code:
    update-alternatives --install java java /opt/jdk1.6.0_04/bin/ 1
    update-alternatives --config java
    Then select the number for your newly installed jdk.

    Mike

  10. #10
    Join Date
    Sep 2009
    Beans
    1

    Re: Yet Another Way to Install Java 6

    Thank you so much OP I have been trying to download java for 2 days now nothing worked except your help. I am new to linux this saved my life.

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
  •