Tell Java programs where JAVA_HOME is on Linux.

Java programs like ImageJ may refuse to start because they cannot find JAVA_HOME environment variable. Fix this problem on Linux as follows:

  1. Be sure Java JRE is installed.

    apt install default-jre
  2. Try a command like:

    JAVA_HOME=/usr/lib/jvm/default-java imagej

    where imagej is the Java program of interest.

  3. if the command now works, in ~/.bashrc set

    export JAVA_HOME=/usr/lib/jvm/default-java