Java – Installing Java 7 on Ubuntu

installationjavaUbuntu

to install java I have always used the classic way from the terminal.
I would like to install java manually.
I placed the folder of the JDK on the desk and I set environment variables (PATH, CLASSPATH and JAVA_HOME).
From the terminal, if I type java -version I get printed

foralobo@ubuntu-vincy:~$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

But when I try to install eclipse or netbeans, the system warns by saying that there is no java installed on the machine.

What is missing to compleatare manual installation?
(Ubuntu 13.04)

Best Answer

This answer used to describe how to install Oracle Java 7. This no longer works since Oracle end-of-lifed Java 7 and put the binary downloads for versions with security patches behind a paywall. Also, OpenJDK has grown up and is a more viable alternative nowadays.

In Ubuntu 16.04 and higher, Java 7 is no longer available. Usually you're best off installing Java 8 (or 9) instead.

sudo apt-get install openjdk-8-jre

or, f you also want the compiler, get the jdk:

sudo apt-get install openjdk-8-jdk

In Trusty, the easiest way to install Java 7 currently is to install OpenJDK package:

sudo apt-get install openjdk-7-jre

or, for the jdk:

sudo apt-get install openjdk-7-jdk

If you are specifically looking for Java 7 on a version of Ubuntu that no longer supports it, see https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher .