W3docs

Installing Java 7 on Ubuntu

To install Java 7 on Ubuntu, you can follow these steps:

To install Java 7 on Ubuntu, you can follow these steps:

Note: Java 7 has reached end-of-life and is no longer available in official Ubuntu repositories. The commands below apply to Ubuntu 14.04 or 16.04, where OpenJDK 7 was included in the default repositories. For Ubuntu 18.04 and newer, Java 7 is not provided by default. For modern systems, it is strongly recommended to install OpenJDK 8, 11, or 17 instead.

  1. Update the package index:

    sudo apt-get update
  2. Install the Java 7 runtime:

    sudo apt-get install openjdk-7-jre
  3. Set the default Java version:

    sudo update-alternatives --config java

    This command will show you a list of available Java versions and ask you to select the default version. Select the Java 7 runtime by typing the corresponding number and pressing Enter. If only one Java version is installed, this step can be skipped.

  4. Verify the installation:

    java -version

    This command should print the Java version, which should be Java 7.