Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't find any .deb packages for Sun's Java Development Kit. How can I install it on my Debian machine without causing conflicts with the already installed openjdk packages?

share|improve this question
up vote 5 down vote accepted

You can create a Debian package from the Oracle tarball using the make-jpkg command from the java-package package. Here is an example:

make-jpkg jdk-7u45-linux-x64.tar.gz

You can then install the resulting .deb file with dpkg -i:

sudo dpkg -i oracle-java7-jdk_7u45_amd64.deb 

Finally, make this the default Java environment using update-java-alternatives:

sudo update-java-alternatives -s jdk-7-oracle-x64

Source: https://wiki.debian.org/Java/Sun

share|improve this answer
Damn, talk about reinventing the wheel. I'd read the wiki page and stopped at "Sun Java is no longer available in the repositories." :). Anyway, updated your answer with what I had to do to get it to work. Thanks! – terdon Dec 29 '13 at 12:00
Heh! Even AU doesn't have this method. – Braiam Dec 29 '13 at 12:49

Please use @jordanm's solution. My approach works but his is easier and requires less manual intervention.

The latest version of Sun's JDK can be found on their website here:

They don't offer .deb packages (only .rpm) so you will need to download the .tar.gz package for your architecture. In my case this was jdk-7u45-linux-x64.tar.gz. Once the package has been downloaded, extract it and move the expanded directory to /usr/lib:

tar xvzf jdk-7u45-linux-x64.tar.gz 
sudo mv jdk1.7.0_45/ /usr/lib/

You now need to tell Debian to use it. This is done through the nifty update-alternatives command. You need to run this once for each program in /usr/lib/ jdk1.7.0_45/bin to tell your system to use Sun's versions of these programs. You can combine the three in a little shell loop:

for i in /usr/lib/jdk1.7.0_45/bin/*; do 
 i=$(basename $i); 
 sudo update-alternatives --install /usr/bin/$i $i /usr/lib/jdk1.7.0_45/bin/$i 1081; 

On my system, the installed openjdk executables had a priority of 1071 which is why I used 1081 in the above example. Your case might be different so once you have run the commands above, make sure the right executable has been chosen by running

sudo update-alternatives --config java

The default (the one with the *) should be the JDK version you just installed. You can do the same for javac and javaws. You can use the same command to switch back and forth between available java executables.

share|improve this answer
I've never understood why Oracle/Sun do not distribute .deb files for Java. They have practically every other OS there would one more really break Oracle? To me this says it all as far as Oracle's opinion of Debian/Ubuntu. – slm Dec 29 '13 at 1:53
@slm yeah, it is weird. Is that a smug grin I see you hiding RH man? – terdon Dec 29 '13 at 1:55
Maybe just a smirk 8-). It's more b/c Oracle's Unbreakable Linux is why RPMs are available, and that a large customer base that use Java serve it on RHEL. – slm Dec 29 '13 at 1:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.