JAVA_HOME is not valid - runtime fail

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

Best thing to do is just set JAVA_HOME appropriately in your environment.

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.

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

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.

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.

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

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.

Thanks

*R

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)

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.

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

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

Its a short read, hopefully it’s helpful.:thinking:

1 Like

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.

1 Like

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:

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

Best regards
Stephan