Installing jdk7 in Ubuntu

Today i wanted to try the new version of jdk and see how is the project going. Last time i checked it was too buggy to setup so i was a bit of disappointed. As I using ubuntu on my laptop i wanted to check if my distro is providing a development package for the new vm but that wasn’t the case :( . Luckily the jdk project provides some nice prepackaged binaries you can install yourself over here. After getting the binaries for my architecture(x64) and unpacking the archive i got a jdk1.7.0 directory. In ubuntu it pretty easy to set your platform default options and the tool for this is update-alternatives. Here are the commands if you have Ubuntu:

Move the directory to the jvm directory where it should reside:

sudo mv jdk1.7.0/ /usr/lib/jvm 

Check how many alternatives you have:

sudo update-alternatives --config java

Install the new alternative:

sudo update-alternatives --install /usr/bin/java java 
/usr/lib/jvm/jdk1.7.0/jre/bin/java 2

where 2 should be the next unused index from the last command. So if you have 2 java alternatives your new installation should have index 3

Set the platform default to be the new option:

update-alternatives --config java

Now all your java applications will use the new jdk. I cannot tell the difference but as I work more with eclipse and other java tools i will be make my opinions and might share them here :)

Happy coding

14 thoughts on “Installing jdk7 in Ubuntu

  1. The instructions are pretty straightforward. It shouldn't be too hard to figure it out from the post :) . Please write in lowercase letters so you don't look so noisy. Best regards nikolavp

  2. Nope u cannot use the jdk7 features in eclipse. Eclipse uses an internal compiler that most probably needs to be patched by them to take advantage of the new features.
    Netbeans on the other hand should support them but this is a different story..

  3. Yeah, I have made a brief look at this and posted small post highlighting eclipse, idea and netbeans status with JDK7

  4. Nice post and always good to include terminal commands. Just fyi you don't have x64 arch. you have 64bit arch. x86 refers to 8086, 80186, 80286 … which are 32bit archs. Neway take care.

  5. Hmm I thought they call it that way and wikipedia "says" the same:
    "After launching the architecture under the "x86-64" name, AMD renamed it AMD64 in 2003;[3] Intel initially used the names IA-32e and EM64T before finally settling on Intel 64 for their implementation. x86-64 is still used by many in the industry as a vendor-neutral term, while others, notably Sun Microsystems[4] (now Oracle Corporation) and Microsoft,[5] use x64."


    not sure which is more correct :)


  6. Hi, I'm using Ubuntu 10.10… And I followed the instructions well, but when I enter the command " $ java -version " I get " bash: /usr/bin/java: cannot execute binary file"

  7. Hi,

    Most of the time this error message is caused when you didn't download the binaries for your CPU architecture.

    Best, Niki

  8. The jdk is a set of tools that will enable you to program in the java programming language for the java virtual machine.

    This tutorial will actually only set the "java" program on your path(means when you call java, it will call the jdk7 java). This will not put the other tools from the jdk in your path(jps comes to mind)

    In that manner I am not sure what do you mean by "Don't know how to launch the jdk environment."

    If by that you mean start the java virtual machine – then "java" in the shell will be enough.

    Best, Niki

Leave a Reply to Ruben Martinez Cancel reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>