cd98 cd98 - 3 years ago 452
Java Question

h2o failed to connect when called from R: Java version missmatch

was working before on my laptop, but I didn't use it for a while
(and have installed new packages and updated things in the meantime). Yesterday I tried using it, but it didn't work. I erased the
packaged and I've reinstalled
from scratch with


I tried running
but it gives me this error

java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Starting H2O JVM and connecting: ............................................................
[1] "localhost"
[1] 54321
[1] TRUE
[1] -1
[1] "Failed to connect to localhost port 54321: Connection refused"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 54321: Connection refused
[1] 7
Error in h2o.init() : H2O failed to start, stopping execution.

When I look at the error log it shows

Only Java 1.6-1.8 supported, version is 9

I tried to look for more info and I think the error is triggered by this code on line 1836:

if (version != null && !(version.startsWith("1.6") || version.startsWith("1.7") || version.startsWith("1.8"))) {
System.err.println("Only Java 1.6-1.8 supported, version is " + version);
return true;

So it seems
is checking for a version that starts with 1.6, 1.7 and 1.8 but my version for some reason starts with 9!
However, on the terminal,
java -version

openjdk version "1.8.0_121"
OpenJDK Runtime Environment (Zulu (build 1.8.0_121-b15)
OpenJDK 64-Bit Server VM (Zulu (build 25.121-b15, mixed mode)

which java


------------ EDIT -------

More info:
/usr/libexec/java_home -V

Matching Java Virtual Machines (4):
9, x86_64: "Java SE 9" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
1.8.0_144, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
1.8.0_51, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
1.8.0_25, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

Which explains the
is seeing. I find it weird that it expects
but the version is just
. In any case, it seems I need to point that
command to the
java, but I couldn't figure out how to do it.

I usually use
to install most things, but I never use
so I don't know anything about the versions.

Thanks and best!

Answer Source

The error you reported says:

Only Java 1.6-1.8 supported, version is 9

Seems like you have Java 9 installed, which is not yet supported by H2O. Use a compatible version of Java and that will fix the error.

If you can't or don't want to uninstall Java 9, then you'll need to tell H2O which Java you'd like to use by setting the JAVA_HOME environment variable. First, get the location of Java 1.8 by executing the following in a shell:

/usr/libexec/java_home -v 1.8

On my mac, it shows me this:


You can check if R can see your JAVA_HOME variable by running the following command: Sys.getenv("JAVA_HOME").

If that's blank (and possibly will be if you're using RStudio), then will have to do a bit more work to get R to see the JAVA_HOME variable. You can edit the ~/.Renviron file to add JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home or whatever that location is on your machine. Then restart RStudio and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download