Skip to main content

Java

How do I use H2O with Java?​

H2O supports two integration approaches: using the REST API or embedding H2O within your Java application.

  • Using the REST API:

    The simplest way is to call the REST API from your Java program to a remote cluster and should meet the needs of most users.

    You can access the REST API documentation in our REST API reference documentation.

    Python and R both rely on the REST API to run H2O. Most R and Python API calls translate into a single REST API call.

    To see how the REST API is used with H2O:

    • Run an H2O client with logging enabled and review the REST calls it makes.
    • Write an R program for H2O using the H2O R package that uses h2o.startLogging() at the beginning. All REST API calls used are logged.
  • Embedding H2O within your Java application:

    The second way to use H2O with Java is to embed H2O within your Java application. An example describing how to do this is available in the h2o-droplets repository.


How do I communicate with a remote cluster using the REST API?​

Download the H2O distribution zip file by following the steps in Downloading and installing H2O-3 Secure. The distribution zip includes a file named h2o-bindings-<version>.zip. This file contains all of the Java bindings necessary for communicating with a remote cluster via the REST API. The REST API reference documentation is available on our documentation site.


I keep getting a message that I need to install Java. I have a supported version of Java installed, but I am still getting this message. What should I do?​

This error message displays if the JAVA_HOME environment variable is not set correctly. The JAVA_HOME variable is likely points to Apple Java version 6 instead of Oracle Java version 8.

If you are running OS X 10.7 or earlier, enter the following in Terminal:

export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

If you are running OS X 10.8 or later, modify the launchd.plist by entering the following in Terminal:

cat << EOF | sudo tee /Library/LaunchDaemons/setenv.JAVA_HOME.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.JAVA_HOME</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>JAVA_HOME</string>
<string>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
EOF

Feedback