<< BSOF Comes To The Mac | Home | The Wall Of Erasure >>

Getting Sun Java 6 On Debian 4.0 With APT Pinning

All the noise about Leopard and Java6 last week made me thinking: Does my favorite operating systems include the JDK? And if so, which version?

The answer, of course, is that Windows does come with a JRE, but it's at version 1.1; and that Debian comes with a incomplete open source JRE that's roughly at version 1.4.

Debian 4.0, however, makes getting the higher versions of Java easy. Sun Java 5 is available in Debian 4.0's stable software repository, while Sun Java 6 is available in the Debian unstable software repository. Since neither are free software, they can only be found in the non-free section of the repositories.

Enabling the non-free section of the stable repository in very easy, as I documented here 136 days ago.

Enabling the unstable repository in Debian 4.0 is something that I don't want to do lightly, for I don't want to upgrade every package in my system to the bleeding edge, at least not yet. Jonathan mentioned "APT pinning" when I asked him about this at the time. And learning about APT pinning I did yesterday.

The three degrees of APT pinning

I have gone through three documents that I found on the Google about APT Pinning.

First there's the very clear Apt-Pinning for Beginners. It outlines exactly what to do to enable the testing and unstable repositories in Debian in such a way as to favor the stable repositories's contents.

But I have some unanswered questions, so I went to the Debian Wiki's AptPinning page. It provided a few more recipe's of doing APT pinning. I particularly like the "only if I say so" approach.

But I still have some unanswered questions, so I went to the authoritative source—the man page of apt_preferences(5). This man page is on my hard drive all along. And to read a printed out copy I issued the command

[weiqi@gao]$ man -Tps apt_preferences | lpr

This six-page document contains explanations of every detail of the things that I need to do.

The steps

Here's the steps I took to get Sun JDK 6 to my Debian GNU/Linux 4.0 system (the right way):

  1. Add a line to /etc/apt/sources.list:
    # deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official amd64 DVD Binary-1 200704
    07-12:15]/ etch contrib main
    
    deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official amd64 DVD Binary-1 20070407
    -12:15]/ etch contrib main
    
    deb http://ftp.debian.org/debian/ etch main non-free
    deb-src http://ftp.debian.org/debian/ etch main non-free
    
    deb http://security.debian.org/ etch/updates main contrib non-free
    deb-src http://security.debian.org/ etch/updates main contrib non-free
    
    deb http://www.debian-multimedia.org etch main
    deb http://www.dipconsultants.com/debian etch main
    
    ### unstable #######
    deb http://ftp.debian.org/debian/ unstable main non-free
  2. Add a line to /etc/apt/apt.conf.d/70debconf:
    // Pre-configure all packages with debconf before they are installed.
    // If you don't like it, comment it out.
    DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};
    APT::Cache-Limit "100000000";
  3. Created /etc/apt/preferences:
    Package: *
    Pin: release a=stable
    Pin-Priority: 700
    
    Package: *
    Pin: release a=unstable
    Pin-Priority: 600
  4. Run apt-get update
  5. Install the eight sun-java6-* packages
    • sun-java6-bin
    • sun-java6-demo
    • sun-java6-doc
    • sun-java6-fonts
    • sun-java6-javadb
    • sun-java6-jdk
    • sun-java6-jre
    • sun-java6-source
    with
    [root@gao]# feta install <package-name>s
    Notice that the sun-java6-doc package requires that I download the JDK documentation from Sun's Java download site and put the zip file in /tmp.
Tags :


Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Worked like a charm. thanks for posting this info.

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Thank you for the feedback. It's always good to know that what I wrote actually worked for somebody somewhere somehow.

I write my blog for moments like this.

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Great help. Thanks alot.
In case others have a problem getting Eclipse to work with java6 in Debian or Ubuntu.
From: http://ubuntuforums.org/showthread.php?t=201378
you may need to edit Eclipse's java_home file
gedit /etc/eclipse/java_home
and add
/usr/lib/jvm/java-6-sun
to the top of the file.

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Thanks a lot buddy..I was breaking my head on this to get limewirepro installed on my deb machine and this really solved my problem!

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

worked great - thanks . . . then went into /etc/init.d/tomcat5.5 and added /usr/lib/jvm/java-6-sun to the beginning of the list of directories and voila ... tomcat5.5 came up nicely

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

This is really awesome. I spent two hours trying to install Java 6, then I found this. I understand about 10 % of what I've done, but it works! It's really great what you can accompish by a bunch of anonymous friend. Thanks.

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

You are the best ;)

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Great work! Your post changed my life! At first I installed java the crude way (direct download and install without using apt) But I was always worried about updates. But the same time I don't want everything to be updated to the very latest in the unstable branch. So your post just hit the bulls eye. Thanks so much!

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Great blog entry, thank you!

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Thanks, this helped me too!

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Hi,
Thank you a lot.
This is great. It helped me.
Long life to Debian.
:)

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Thanks It wokred for me only adding : deb http://ftp.debian.org/debian unstable non-free to sources.lst apt-get update apt-get install sun-java6-jdk

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Thanks so much, it worked perfectly. Much easier to follow than the other method also!

Re: Getting Sun Java 6 On Debian 4.0 With APT Pinning

Vielen Dank auch aus Deutschland! Thank you a lot, also from Germany

Add a comment Send a TrackBack