# JAVA\_HOME is not valid - runtime fail

**URL:** <https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216>\
**Category:** Runtime\
**Created:** [September 17, 2016, 11:55pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216 "2016-09-17T23:55:33Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![rheine3](https://community.openhab.org/user_avatar/community.openhab.org/rheine3/32/71619_2.png) [@rheine3](https://community.openhab.org/u/rheine3)\
**Post date:** [September 17, 2016, 11:55pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/1 "2016-09-17T23:55:33Z")

</div>

Just loaded OHAB2 and the runtime popped open and closed. Put a PAUSE in the karaf.bat file near the beginning.

JAVA\_HOME is not valid

Apparently it’s not finding a path in the REG file. I searched the whole HKEY\_LOCAL\_MACHINE for JAVA\_HOME and did not find it. OpenHAB 1 worked fine. My JAVA is 1.8.

Any ideas or suggestions.

\*R

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [September 18, 2016, 12:52am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/2 "2016-09-18T00:52:13Z")

</div>

Best thing to do is just set JAVA\_HOME appropriately in your environment.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [September 18, 2016, 1:03am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/3 "2016-09-18T01:03:52Z")

</div>

Set a JAVA\_HOME environment variable.

Right Click “My Computer” / “Computer” / “This PC” (depending on which version of Windows you are running) and select “Properties”. From here where the environment variables are differs based on which version of Windows you have. If on Windows 10 press “Advanced System Settings” and there is a button called “Environment Variables”.

You will have to restart explorer.exe or reboot for the changes to be picked up.

Java does not use the registry for JAVA\_HOME.

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [September 18, 2016, 1:09am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/4 "2016-09-18T01:09:17Z")

</div>

> Java does not use the registry for JAVA\_HOME

In OH2, it appears that the registry IS tried as a fallback mechanism under certain circumstances:

> :TryJRE  
> start /w regedit /e \_\_reg1.txt “HKEY\_LOCAL\_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment”  
> if not exist \_\_reg1.txt goto :TryJDK

---

<div class="post-metadata">

**Author:** ![rheine3](https://community.openhab.org/user_avatar/community.openhab.org/rheine3/32/71619_2.png) [@rheine3](https://community.openhab.org/u/rheine3)\
**Post date:** [September 18, 2016, 1:12am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/5 "2016-09-18T01:12:57Z")

</div>

I created a new system environment variable by the same name and pointed it to  
C:\Program Files (x86)\Java\jdk1.8.0\_102\bin

Still no go.

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [September 18, 2016, 1:16am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/6 "2016-09-18T01:16:46Z")

</div>

Are you starting OH from a command window? It would help to show the output of “set JAVA\_HOME” followed by the output from your startup attempt.

---

<div class="post-metadata">

**Author:** ![rheine3](https://community.openhab.org/user_avatar/community.openhab.org/rheine3/32/71619_2.png) [@rheine3](https://community.openhab.org/u/rheine3)\
**Post date:** [September 18, 2016, 1:40am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/7 "2016-09-18T01:40:24Z")

</div>

Not getting that far now.

C:\OpenHAB-2\>start.bat  
Launching the openHAB runtime…  
Files was unexpected at this time.

C:\OpenHAB-2\>

Not making it to karaf I think

---

<div class="post-metadata">

**Author:** ![rheine3](https://community.openhab.org/user_avatar/community.openhab.org/rheine3/32/71619_2.png) [@rheine3](https://community.openhab.org/u/rheine3)\
**Post date:** [September 18, 2016, 2:05am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/8 "2016-09-18T02:05:11Z")

</div>

VIOLA! I added the path to JDK in the system environment variable PATH, restarted explorer and away she went. I hope this will help others.

> <https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7/17142065#17142065>

Thanks

\*R

---

<div class="post-metadata">

**Author:** ![MDAR](https://community.openhab.org/user_avatar/community.openhab.org/mdar/32/57900_2.png) [@MDAR](https://community.openhab.org/u/MDAR)\
**Post date:** [August 21, 2018, 12:43pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/9 "2018-08-21T12:43:03Z")

</div>

I’m having a similar issue in Linux Ubuntu 16, since I tried to swap the Java version.

OpenHab2 and everything associated with it was working, I just wanted to try to change it from Oracle 8 to Zulu 8.

which just didn’t work on this particular machine, so I swapped back to OpenJDK version 1.8.0\_181

OpenHab2 now runs fine, but for some reason when I try to start the openhab-cli console  
I get this error

```
JAVA_HOME is not valid: /usr/lib/jvm/java-8-oracle

```

Is there a file I need to tweak within OpenHab2 to set the correct JAVA\_HOME variable?

java -version responds with ;

```
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK Server VM (build 25.181-b13, mixed mode)

```

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [August 21, 2018, 2:04pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/10 "2018-08-21T14:04:16Z")

</div>

With Oracle Java, assuming you installed using the webupd8team PPA, has an `sudo apt-get install oracle-java8-set-default` which will configure everything so Oracle Java is the default on your system. I don’t know what it all does but suspect it sets up symbolic links and modifies /etc/defaults files.

---

<div class="post-metadata">

**Author:** ![MDAR](https://community.openhab.org/user_avatar/community.openhab.org/mdar/32/57900_2.png) [@MDAR](https://community.openhab.org/u/MDAR)\
**Post date:** [August 21, 2018, 3:45pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/11 "2018-08-21T15:45:49Z")

</div>

Umm

That’s that I thought might be happening, but I just can’t find a file that still points to Oracle.

FYI  
I can’t find a file in /etc/defaults that looks like it might hold the answer..

Oh well, a good try

---

<div class="post-metadata">

**Author:** ![H102](https://community.openhab.org/user_avatar/community.openhab.org/h102/32/25595_2.png) [@H102](https://community.openhab.org/u/H102)\
**Post date:** [August 21, 2018, 6:00pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/12 "2018-08-21T18:00:37Z")

</div>

> [@MDAR](#):
>
> Is there a file I need to tweak within OpenHab2 to set the correct JAVA\_HOME variable?

[https://community.openhab.org/t/how-to-point-oh2-to-a-different-java-version/18665](https://community.openhab.org/t/how-to-point-oh2-to-a-different-java-version/18665)

Its a short read, hopefully it’s helpful.🤔

---

<div class="post-metadata">

**Author:** ![badosanjos](https://community.openhab.org/user_avatar/community.openhab.org/badosanjos/32/36496_2.png) [@badosanjos](https://community.openhab.org/u/badosanjos)\
**Post date:** [September 22, 2020, 1:03pm UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/13 "2020-09-22T13:03:35Z")

</div>

I did the install yesterday and had problems with the Java. I received the message " 8 was unexpected at this time " . I edited all the the .bat files and deleted the first line “@echo off”, with this I started to see all the actions into the command line and I discovered that into the file runtime\bin\setenv.bat there was a line adding “/java/bin” to the end of the Java Path causing the trouble (use the locate ctrl+f to find it), so I deleted this “/java/bin” text and the instalation worked fine.

---

<div class="post-metadata">

**Author:** ![Sofa1780](https://community.openhab.org/user_avatar/community.openhab.org/sofa1780/32/76053_2.png) [@Sofa1780](https://community.openhab.org/u/Sofa1780)\
**Post date:** [November 5, 2022, 11:22am UTC](https://community.openhab.org/t/java-home-is-not-valid-runtime-fail/14216/14 "2022-11-05T11:22:49Z")

</div>

HI,

in my case (Ubuntu Server OS, OH-Docker-Image V.3.3.0)  
opening the bash console of the container results in the same issue.

I fixed it by setting the system environment variable accordingly, depending on my current Java home path:

```auto
docker exec -it openhab bash
export JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64/

```

Best regards  
Stephan
