Installing Java 7 on Debian Squeeze

For all of my servers I use Debian, however that distribution has a few problems, mainly the packages can be a bit behind the cutting edge.

Now this is usually a good thing if you are looking for stability – cutting edge software can have issues, especially from new features etc, so for a live environment you want something thats stable.

However, there does come a time when this can bite back. You either need a feature thats not in the standard repositories or in this case the version is now unsupported.

In Debian Squeeze it has Java 6 – but that was EOL’d a couple of months ago so is no longer supported by Oracle. The current version is Java 7 update 17.

So how do we get Java 7 installed?

Well it’s pretty easy to do, we just need to add another repository into apt and install it.

First the repository:

sudo su -
echo "deb precise main" | tee -a /etc/apt/sources.list
echo "deb-src precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver --recv-keys EEA14886
apt-get update

What that does is to install the ubuntu ppa repository into apt, setup the public keys and then load the package lists.

Next we need to install it:

sudo apt-get install oracle-java7-installer

This will now download Oracle Java 7 and present you with a couple of screens about licensing. Just ok and accept it and it will now install.

That’s it. You now have Java 7 installed – but it’s not the default JDK (if you already had Java 6 installed). If you want it to be the default then there’s just one more thing to do:

sudo apt-get install oracle-java7-set-default

That’s a dummy package but it will make Java 7 the default on that machine. If you want to check then you can check:

peter@titan ~ $ java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Tagged , , , , , , ,

19 thoughts on “Installing Java 7 on Debian Squeeze

  1. mad says:

    thank you for this share

  2. Francesco says:

    It works well thanks!!!
    but when I start synaptic I have this error now:

    E: The value ‘stable-updates’ is invalid for APT::Default-Release as such a release is not available in the sources
    E: _cache->open() failed, please report.

    • petermount1 says:

      What version are you running this on?

      I’ve not seen that error and I’ve used this for not just Debian but the last two versions of Linux Mint as well.

      The only thing I can think of is that there’s a conflict with another repository

  3. […] La mayoría del contenido de este post proviene de esta página: Installing Java 7 en Debian Squeeze. […]

  4. Sven Varkel says:

    Thanks for useful and correct instructions!

  5. Bob says:

    I’ve switched to Centos for servers and never looked back. Debian packages are always too stale.

  6. Vaclav says:

    Thanks for sharing Peter!

  7. Thank you! It works perfectly.

  8. jorge says:

    wooowww!!!! excellent!!! thanks!!!!

  9. Leo Salas says:

    Worked exactly as described. Many thanks!

  10. Vince says:

    After a bit of downloading I keep getting “Connection closed at byte 125829120. Retrying.”

  11. leec says:

    Thank you. Installed JDK and JRE 7 on Debian Squeeze running on an Intel NUC. Now on to download the latest Android Studio release…

  12. Do you have any idea if Java 8 can be run on Squeeze?

    • petermount1 says:

      I’m not certain as I’m now using Debian 7 rather than 6 now but in theory yes.

      What I’ve done these days is to install java manually (say under /usr/local/java/ then version) and point the apps to the appropriate JDK. That way I can control when to update it – which is important on a production machine.

      Anyhow, Java8 definitely works in that situation as I’m now using that one across the board.

  13. professortom says:

    Do you know if you can install Java 8 on Squeeze?

  14. MK says:

    Thanks, this made it so I could get Android Studio going on my AVLinux install. Thank you thank you….!!!

  15. Thanks.The information which you have provided is very good and easily understood.
    It is very useful who is looking for Hybris.

Leave a Reply

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

You are commenting using your 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: