How can I install Java on Ubuntu 12.04?
- Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
- Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
To install the latest version of Oracle Java (the latest posted in the Oracle webpage), the easiest way is to use the Java Installer (as flashplugin-installer does) as here is explained: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads (and installs) Oracle Java JDK 7 from its official website and installs it on your computer, just like the flashplugin-installer package does.
Then, you have to do only this:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer
And type this to check the version:
PPA are not a secure / smart way of installing something. Installing JDK is very simple and straightforward.
The Steps are as followed:
Download latest jdk from Oracle's site and extract:
tar -xvf jdk-7u51-linux-x64.tar.gz mkdir -p /usr/lib/jvm mv ./jdk1.7.0_51/ /usr/lib/jvm/jdk1.7.0_51/
Create some symbolic links:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_51/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_51/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_51/bin/javaws" 1
Similarly, symbolic links can be created for other commands of JAVA. Other available commands are:
Ensure right users have the right permission:
sudo chmod a+x /usr/bin/java sudo chmod a+x /usr/bin/javac sudo chmod a+x /usr/bin/javaws sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
Reference: Coders of tHe Dark | Blog
As said above installing from that PPA is the easiest way to do it. Though it might take a day or two for it to be updated to the newest version 7u25. If the problem you experience is a pop-up window saying "Application blocked by security settings", and you really need to use java right now, you can bypass it by decreasing you security level for java. Go to your menu -> preferences -> Oracle java 7 plugin control panel. In there open the security tab, and move the slider to "medium", and apply. That should do the trick.
Hope it helps.
If you get error message like
couldn't resolve host 'launchpad.net' and you sure your proxy server settings are correct (http_proxy and https_proxy)
sudo -E add-apt-repository ppa:tualatrix/ppa