This question already has an answer here:

Today I try to install openjdk 7 on my ubuntu 18.04 system. It always install oracle-java8-installer instead openjdk 7. Please help me

apt-get install openjdk-7-jre

marked as duplicate by karel, Kulfy, Zanna, Eric Carvalho, Fabby Dec 24 '18 at 22:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Ubuntu has removed JDK 7 from the repository. Also, it is no longer supported for any further updates. So you better install jdk8. – Kulfy Jul 10 '18 at 8:19
  • If you still want it you can download from here oracle.com/technetwork/java/javase/downloads/… – Kulfy Jul 10 '18 at 8:20
  • 1
    thanks for the answer, but I want to install openjdk, not Oracle jdk – duongtan Jul 10 '18 at 14:53

Here you got a very good answer with a step-by-step instruction:
Download it here from Oracle.


I have installed OpenJDK 1.7 on Ubuntu 18.04

Step 1. Install OpenJDK 1.7

sudo dpkg -i https://packages.debian.org/sid/libjpeg62-turbo
sudo dpkg -i https://packages.debian.org/experimental/openjdk-7-jre-headless
sudo dpkg -i https://packages.debian.org/experimental/openjdk-7-jre
sudo dpkg -i https://packages.debian.org/experimental/openjdk-7-jdk

Step 2. Switch to OpenJDK 1.7

export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH

Note: If you want to use javac command instead of openjdk 1.7, use below command

sudo update-alternatives --config java

Not the answer you're looking for? Browse other questions tagged or ask your own question.