Home > Linux > Install latest SUN JDK on Ubuntu 11.10

Install latest SUN JDK on Ubuntu 11.10

  1. Open up a terminal and type the following command
  2. sudo update-alternatives --config java 
  3. this should show you the current java version in the system and the currently selected one (note the “*” )
  4. if there is only one java package installed, you might not see a list – but a message like
    There is only 1 program which provides java
    (/usr/lib/jvm/java-6-openjdk/jre/bin/java). Nothing to configure.
  5. on a vanilla ubuntu install, this will default to the open-jdk that comes by default
  6. To install the latest sun-jdk, download the required tar.gz package from http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html
  7. Unpack this and move it to “/usr/lib/jvm”  – u will see another folder there “java-6-openjdk” – this one comes default with Ubuntu
  8. Next we need to change the java source – download a script  from here http://webupd8.googlecode.com/files/update-java-0.5b
  9. just make a “.sh” file with the script – you can see what the script actually does – just open it with gedit
  10.  just run the script using sudo bash filename.sh – it should give you options
  11.  select the one in /usr/lib/jvm/jdk-7 
  12. execute the command: sudo update-alternatives --config java - you should see what java version is being used
    Selection Path Priority Status
      0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto   mode
      1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
    * 2 /usr/lib/jvm/jdk1.7.0_02/jre/bin/java       1 manual mode
  13. you can also verify using the command: java -version
Categories: Linux
  1. March 11, 2012 at 12:28 PM

    Running Xubuntu 11.10 on Lenovo X220

    Unable to see alternatives:-(

    sudo update-alternatives –config java
    [sudo] password for me:
    update-alternatives: error: unknown argument `–config’

    • March 11, 2012 at 4:51 PM

      I think this is because of a copy paste error into the terminal – note that there is a double minus (–) before config – i have updated the post and made it easier to copy the command – try typing in the command – it will show you the currently installed version

  2. tsr
    March 17, 2012 at 12:26 PM

    Using “java –version” at the end, I get the following output
    bash: /usr/bin/java: Permission denied

    But when I revert back to java-1.6.0-openjdk with the same script it works fine.

    • March 19, 2012 at 3:05 AM

      try issuing the command as root
      when i issue the command “java -version” this is what i can see

      java -version
      java version “1.7.0_02”
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)

  3. sam
    October 3, 2012 at 9:29 AM

    when i try java -version got this error :
    sampath@sampathkumar-Breeze:/usr/lib/jvm/jdk1.7.0$ java -version
    bash: /usr/bin/java: cannot execute binary file

    • October 3, 2012 at 8:55 PM

      my guess is that you might have the wrong version of java ( 32 bit vs 64 bit )

  4. Jit
    August 8, 2013 at 5:14 PM

    thank you ..it helps a lot

  1. March 11, 2012 at 5:02 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: