# ERROR! You do not have the Java Runtime Environment installed, please install Java JRE from https://adoptopenjdk.net/?variant=openjdk11 and try again

**URL:** <https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267>\
**Category:** HiveMQ Community Edition\
**Created:** [July 20, 2020, 9:18am UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267 "2020-07-20T09:18:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chengxiangwang](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@chengxiangwang](https://community.hivemq.com/u/chengxiangwang)\
**Post date:** [July 20, 2020, 9:18am UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267/1 "2020-07-20T09:18:04Z")

</div>

I am very sure I have installed jdk11, but when i start the hivemq by `systemctl start hivemq`, this error is always printed.

Here is how i configured java :

```
    export JAVA_HOME=/usr/lib/jvm/jdk-11.0.7
    export PATH=$JAVA_HOME/bin:$PATH
    export HIVEMQ_HOME=/opt/hivemq
    export HIVEMQ_USER=root

    [root@paasm1 ~]# which java
    /usr/lib/jvm/jdk-11.0.7/bin/java
    [root@paasm1 ~]#

    [root@paasm1 ~]# java -version
    java version "11.0.7" 2020-04-14 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS, mixed mode)

```

And here is the hivemq environment:

wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww [root@paasm1 ~]# cat /etc/systemd/system/hivemq.service  
[Unit]  
Description=HiveMQ Community Edition  
After=network.target

```
[Service]
Group=root
User=root
LimitNOFILE=infinity
StandardOutput=null
StandardError=journal
WorkingDirectory=/opt/hivemq
ExecStart=/opt/hivemq/bin/![](file:///C:\Users\xiangwang\AppData\Roaming\Tencent\QQ\Temp\%W@GJ$ACOF(TYDYECOKVDYB.png)run.sh
KillMode=process
Restart=always
KillSignal=15
SuccessExitStatus=143
TimeoutStopSec=3600

[Install]
WantedBy=multi-user.target

[root@paasm1 ~]# cat /etc/init.d/hivemq
#!/bin/bash
# Copyright 2019 dc-square GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# chkconfig: 35 90 12
# description: HiveMQ start script
#
# Set HiveMQ Home to correct path, default is /opt/hivemq
HIVEMQ_HOME=/opt/hivemq
HIVEMQ_USER=root
#
# Get function from functions library
. /etc/init.d/functions
# Start the service HiveMQ
start() {
        if ps ax | grep -v "grep" | grep -q hivemq.jar ; then
        echo -n HiveMQ server already running
        failure $"HiveMQ start"
        echo; else
        echo -n Starting HiveMQ server
        $HIVEMQ_HOME/bin/run.sh >/dev/null 2>&1 &
        ### Create the lock file ###
        touch /var/lock/subsys/hivemq
        success $"HiveMQ server started"
        echo; fi
}
# Restart the service HiveMQ
stop() {
        echo -n Stopping HiveMQ server
        #killproc hivemq
        pkill -f hivemq.jar
        #wait for cleanups
        while ps ax | grep -v "grep" | grep -q hivemq.jar;
        do
        sleep 1
        done
        ##
        if ps ax | grep -v "grep" | grep -q hivemq.jar ; then failure $"HiveMQ shutdown"; else success $"HiveMQ shutdown"; fi
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/hivemq
        echo
}
# Echo the current status of HiveMQ
status() {
	if ps ax | grep -v "grep" | grep -q hivemq.jar ; then echo HiveMQ is running; else echo HiveMQ stopped; fi
}
### main logic ###
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload|condrestart)
        stop
        start
        ;;
  status)
        status
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload}"
        exit 1
esac
exit 0
[root@paasm1 ~]#
```

---

<div class="post-metadata">

**Author:** ![DKrueger](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@DKrueger](https://community.hivemq.com/u/DKrueger)\
**Post date:** [July 20, 2020, 1:14pm UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267/2 "2020-07-20T13:14:26Z")

</div>

Where do you export the Java Home variable? Depending on the exact location, the variable is set in different shells - or not. See [https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) for more details.

---

<div class="post-metadata">

**Author:** ![chengxiangwang](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@chengxiangwang](https://community.hivemq.com/u/chengxiangwang)\
**Post date:** [July 21, 2020, 1:51am UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267/3 "2020-07-21T01:51:54Z")

</div>

Thank you for the reply!

I export JAVA\_HOME/PATH/HIVEMQ\_HOME in the /etc/profile.

---

<div class="post-metadata">

**Author:** ![chengxiangwang](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@chengxiangwang](https://community.hivemq.com/u/chengxiangwang)\
**Post date:** [July 21, 2020, 2:46am UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267/4 "2020-07-21T02:46:32Z")

</div>

I figured out that the JAVA\_HOME / PATH variable that I set in the /etc/profile can not be get in the run.sh script.  
But I don’t why…

---

<div class="post-metadata">

**Author:** ![DKrueger](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@DKrueger](https://community.hivemq.com/u/DKrueger)\
**Post date:** [July 27, 2020, 11:42am UTC](https://community.hivemq.com/t/error-you-do-not-have-the-java-runtime-environment-installed-please-install-java-jre-from-https-adoptopenjdk-net-variant-openjdk11-and-try-again/267/5 "2020-07-27T11:42:20Z")

</div>

systemd is a service in the background. I think it is started before the script in /etc/profile/ is called. You could try this: [https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html](https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html) and set it inside the systemd environment.
