$JAVA_HOME is being removed between boots and it isn't set in the bashrc file. The commands I'm using to set $JAVA_HOME is:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Then I set the path as follows:

export PATH=$PATH:/usr/lib/jvm/java-8-openjdk-amd64/bin
  • Just edit your ~/.bashrc or ~/.profile file and append your two commands to the end of one of those files. – Byte Commander Apr 6 '18 at 11:12
  • I recommend using ~/.profile for this, but the linked post recommends setting it in /etc/environment so that it works for every user. If you do use /etc/environment, be aware that you don't need to export the variable, and you cannot rely on parameter expansion to set the path: whatever you put in the PATH will be literal, so entering exactly the lines you have shown will mess up your PATH very badly and cause most commands to be inaccessible except by their full path – Zanna Apr 6 '18 at 11:17