LinuxInstall 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
  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
  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 – 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. Jit

    August 8, 2013 5:14 pm

    thank you helps a lot
  2. sam

    October 3, 2012 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
    1. October 3, 2012 8:55 pm

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

    March 17, 2012 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.
    1. March 19, 2012 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)
  4. March 11, 2012 5:02 pm

    [...] See my post on how to install SUN JDK [...]
  5. March 11, 2012 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'
    1. March 11, 2012 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

Post a comment

Your email address will not be published. Required fields are marked *