Installing Java 7 Update 25 on 12.04 LTS?

94,770

Solution 1

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:

java -version

Solution 2

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:

appletviewer,apt,extcheck,idlj,jar,jarsigner,javadoc,javafxpackager,javah,javap,java-rmi.cgi,jcmd,jconsole,jcontrol,jdb,jhat,jinfo,jmap,jmc,jps,jrunscript,jsadebugd,jstack,jstat,jstatd,jvisualvm,keytool,native2ascii,orbd,pack200,policytool,rmic,rmid,rmiregistry,schemagen,serialver,servertool,tnameserv,unpack200,wsgen,wsimport,xjc

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

Solution 3

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.

Share:
94,770
Ionică Bizău
Author by

Ionică Bizău

💻 Programmer ⚡️ Geek 🎹 Pianist & Organist 🚀 Learner 💡 Mentor 💫 Dreamer 🍏 Vegetarian 🙏 Jesus follower Website | GitHub | Twitter | PayPal Donations

Updated on September 18, 2022

Comments

  • Ionică Bizău
    Ionică Bizău almost 2 years

    How can I install Java on Ubuntu 12.04?

    I have:

    • Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
    • Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
  • Duncan Jones
    Duncan Jones over 10 years
    Note that on a stock 12.04 install, add-apt-repository is not available. To solve this, run sudo apt-get install python-software-properties.
  • Carlos Quijano
    Carlos Quijano about 9 years
    It works like a charm
  • Greg Dubicki
    Greg Dubicki almost 7 years
    Doesn't work as of July 2017 - 404s when trying to download the binaries from oracle.com...