Old method apt-get install not working with current versions of Ubuntu. If you want to install jdk in Ubuntu 12.04 or later then you need to follow below steps which works for you sure.
Step 1: – Download jdk from oracle website.
Note→ Download Linux x86 OR Linux x64 anyone according to your OS architecture.
Step 2: – We assume that your download folder is Downloads so run below command on terminal
sudo tar -xvf ~/Downloads/jdk-7u21-linux-i586.tar.gz
Replace file name with your downloaded file name.
Step 3: – Now create a directory for jdk in your system using below command
sudo mkdir -p /usr/lib/jvm/jdk7
 
Step 4: – Move all jdk files and folders in to this directory
sudo mv jdk1.7.0_21/* /usr/lib/jvm/jdk7
 
Step 5: – This is final step to install jdk in Ubuntu 12.04 and later. Run below commands to enable Oracle java jdk.
1.  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk7/bin/java" 1
2.  sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk7/bin/javac" 1
3.  sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk7/bin/javaws" 1
After jdk installation in ubuntu check intalled version.
java -version
install jdk in ubuntu

Now you have installed jdk in your Ubuntu 12.04 or later. Enjoy your work!