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
    1. Try a command like:
    JAVA_HOME=/usr/lib/jvm/default-java imagej

    where imagej is the Java program of interest.

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

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