Blue Dogerino

How to install OpenJDK 7 on Ubuntu 18.04

Hello there, if you’re viewing this page you have probably tried building an older version of lineage (i.e. cm-13 and such) and you arrived at an error that looks something like this Error: could not find jdk tools.jar, please check if your JDK was installed correctly. Now this error probably occured because you are using a openjdk that’s newer than OpenJDK version specific for your LineageOS version. As we can see in the official build guide from LineageOS Wiki, OpenJDK 1.7 is needed to build lineagewiki-java

Ok, so to install OpenJDK 7 , it’s a bit of a tricky process, but I hope my guide will assist you in achieving that. Let’s get started!

1.Open up a terminal (for most distros it’s Ctrl+Alt+T, but if your’s doesn’t open one up, look up terminal in your application list)

For purposes of this tutorial I will be using a WSL 2 machine, but this applies to all variants of Ubuntu/Debian derivatives. terminal

2.Do cd ~/Downloads and then wget


3.Next step is to create a directory in the location /usr/local/java and copy the file we just downloaded there


4.What we need to do after copying the file is to enter the directory we previously created and extract the tarball we copied to it


To check if the files extracted correctly do ls -a terminal5

5.Open /etc/profile in nano with sudo privileges and copy the following text at the bottom of the file (PageDown for quicker navigation to the bottom of the file):


export JAVA_HOME
export JRE_HOME
export PATH


6.After saving the file, the next thing you should do is do the following commands, they will update all the paths to the openjdk-7:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_80/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_80/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_80/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jdk1.7.0_80/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_80/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_80/bin/javaws

java-alternatives After u do the following commands, you should reload the profile by using source /etc/profile reload-profile

7.Check your Java version by doing ```java -version

final If it shows u the same output as the picture above you have successfully installed OpenJDK 7.

That’s it, thank you for reading. :D