Where is JAVA_HOME expanded to JAVA_HOME/jre?

1

We have a Tomcat 8 running on Debian 8/jessie.

When starting the tomcat using service tomcat8 start we can see INFO: Java Home: /usr/lib/jvm/java-7-openjdk-amd64/jre

In /etc/default/tomcat8 we have set

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

In /etc/init.d/tomcat8 is JAVA_HOME not set set explicity. Neither in setenv.sh. The environment variable JAVA_HOME is not set.

Background: We have problems with compiling JSP files as the Tomcat can not find the java compiler. We suspect the wrong path for `JAVA_HOME? as it points only to the jre.

Where is JAVA_HOME expanded to JAVA_HOME/jre?

Yeti

Posted 2018-05-09T10:06:38.217

Reputation: 163

Answers

0

I am not getting exactly what your problem is, but think that you couldn't set JAVA_HOME variable properly somehow, So, I will answer assuming this fact.

Adding to /etc/profile

  1. Open /etc/profile in any text editor & add the following line :

    JAVA_HOME="/Path/to/Java/home/directory"
    export PATH=$JAVA_HOME/bin:$PATH
    

    where path in your case is usr/lib/jvm/java-7-openjdk-amd64/

  2. Now, source the profile file to load the variables :

    source /etc/profile
    

Adding to /etc/environment

You can set your JAVA_HOME in /etc/profile, but the preferred location for JAVA_HOME or any system variable is /etc/environment.

  1. Open /etc/environment in any text editor & add the following line :

    JAVA_HOME="/Path/to/Java/home/directory"
    export JAVA_HOME
    

    And path in your case is usr/lib/jvm/java-7-openjdk-amd64/

  2. Now, source the environment file to load the variables :

    . /etc/environment
    
  3. Check the variable being set or not, by echoing it :

    echo $JAVA_HOME
    

NOTE : Usually most linux systems source /etc/environment by default, However, If your system doesn't do that add the following line to ~/.bashrc.

source /etc/environment

Feel free to add-in more details.

C0deDaedalus

Posted 2018-05-09T10:06:38.217

Reputation: 1 375

Thanks for your answer! We have problems with compiling JSP files as the Tomcat can not find the java compiler. We suspect the wrong path for JAVA_HOME as it points only to the jre. – Yeti – 2018-05-09T13:38:50.300

In that case, you should write an answer on your own, stating root cause and the solution. That would help community ! – C0deDaedalus – 2018-05-09T13:42:35.400

I will as soon as we have found a solution. :-) At the moment were are stack with the problem stated above in the question. I will try your answer and see if it helps. :-) – Yeti – 2018-05-09T13:45:25.873