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

亡梦爱人 提交于 2019-12-01 20:30:17

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:

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

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.

I followed the discussion in this thread to get a solution to the problem, though it won't be that convenient for some people.

The default java is 1.8.x, hence once that h2o can use, but calling h2o from R results in the version 9 java getting called.

The (rather patchy) solution for now is to start the h2o server from the terminal like this

cd h2o-3.14.0.3   #navigate to wherever you have the h2o installation
java -jar h2o.jar

with that running fine, I then link it from R without starting an h2o instance:

h2o.init(startH2O = FALSE) 

This works fine if you're ok with starting h2o from the terminal (might be the only way if you're working on a cluster), but might be annoying if you want to start it from RStudio right away.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!