Fixing solr error: The currently defined JAVA_HOME refers to a location where Java could not be found

If you uninstall Java, or it is installed in a way that the solr service can’t see, you can get the following error:

The currently defined JAVA_HOME (/usr/lib/jvm/java-8-oracle) refers
to a location where Java could not be found.  Aborting.
Either fix the JAVA_HOME variable or remove it from the
environment so that the system PATH will be searched.

To fix this, you can edit /etc/default/solr.in.sh, and add the following line (adjust to match your JDK):

SOLR_JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"