Sometimes installing Java can be as if someone stabs you hundreds of pencils in the ass. I had trouble to install the Sun Java6 JDK after updating to Ubuntu 10.04.
The problem was that the system couldn’t find the package sun-java6-sdk and
apt-get gave me a bad message:
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package sun-java6-jdk has no installation candidate
Note on current Debian versions:
SunSDK has been completely removed from the partner archives and the user should move to OpenJDK instead. See also the following links:
You should install OpenJDK instead
sudo apt-get install openjdk-6-jdk
If you still want to run the Sun version:
What I did to solve this problem was to add a new source
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
After that a normal
sudo apt-get update sudo apt-get install sun-java6-jdk
it worked for me.
What you can also do (i did this on Debian Squeeze):
Adding non-free to the
deb http://ftp.debian.org/debian squeeze main contrib non-free
This worked for me for example in the newest Debian 6 (Squeeze) version.
Thanks for the comment of Mark Zhao. You can also update the /etc/apt/sources.list file and add/uncomment the following lines:
deb http://archive.canonical.com/ubuntu lucid partner deb-src http://archive.canonical.com/ubuntu lucid partner
Thanks to the comment of Reinier, it seems that the Sun Java Packages have been removed from the canonical-archive.
Another tip from a comment by user lipin:
sudo add-apt-repository ppa:ferramroberto/java sudo apt-get update sudo apt-get install sun-java6-jdk