class_docstr: Handle to an H2O server launched locally.
  
  Public interface::
  
      hs = H2OLocalServer.start(...)  # launch a new local H2O server
      hs.is_running()                 # check if the server is running
      hs.shutdown()                   # shut down the server
      hs.scheme                       # either "http" or "https"
      hs.ip                           # ip address of the server, typically "127.0.0.1"
      hs.port                         # port on which the server is listening
  
  Once started, the server will run until the script terminates, or until you call ``.shutdown()`` on it. Moreover,
  if the server terminates with an exception, then the server will not stop and will continue to run even after
  Python process exits. This runaway process may end up being in a bad shape (e.g. frozen), then the only way to
  terminate it is to end the Java process from the terminal.
  
  Alternatively, it is possible to start the server as a context manager, in which case it will be automatically
  shut down even if an exception occurs in Python (but not if the Python process is killed)::
  
      with H2OLocalServer.start() as hs:
          # do something with the server -- probably connect to it
class_docstr_tok: ["Handle","to","an","H2O","server","launched","locally",".","Public","interface",":",":","hs","=","H2OLocalServer.start","(","...",")","#","launch","a","new","local","H2O","server","hs.is_running","(",")","#","check","if","the","server","is","running","hs.shutdown","(",")","#","shut","down","the","server","hs.scheme","#","either","``","http","''","or","``","https","''","hs.ip","#","ip","address","of","the","server",",","typically","``","127.0.0.1","''","hs.port","#","port","on","which","the","server","is","listening","Once","started",",","the","server","will","run","until","the","script","terminates",",","or","until","you","call","``",".shutdown","(",")","``","on","it",".","Moreover",",","if","the","server","terminates","with","an","exception",",","then","the","server","will","not","stop","and","will","continue","to","run","even","after","Python","process","exits",".","This","runaway","process","may","end","up","being","in","a","bad","shape","(","e.g",".","frozen",")",",","then","the","only","way","to","terminate","it","is","to","end","the","Java","process","from","the","terminal",".","Alternatively",",","it","is","possible","to","start","the","server","as","a","context","manager",",","in","which","case","it","will","be","automatically","shut","down","even","if","an","exception","occurs","in","Python","(","but","not","if","the","Python","process","is","killed",")",":",":","with","H2OLocalServer.start","(",")","as","hs",":","#","do","something","with","the","server","--","probably","connect","to","it"]
docstr: Find location of the java executable (helper for `._launch_server()`).
  
  This method is not particularly robust, and may require additional tweaking for different platforms...
  :return: Path to the java executable.
  :raises H2OStartupError: if java cannot be found.
docstr_tok: ["Find","location","of","the","java","executable","(","helper","for","`","._launch_server","(",")","`",")",".","This","method","is","not","particularly","robust",",","and","may","require","additional","tweaking","for","different","platforms","...",":","return",":","Path","to","the","java","executable",".",":","raises","H2OStartupError",":","if","java","can","not","be","found","."]
code: def _find_java():
      """
      Find location of the java executable (helper for `._launch_server()`).
  
      This method is not particularly robust, and may require additional tweaking for different platforms...
      :return: Path to the java executable.
      :raises H2OStartupError: if java cannot be found.
      """
      java = "java.exe" if sys.platform == "win32" else "java"
  
      h2o_java = os.getenv("H2O_JAVA_HOME")
      if h2o_java:
          full_path = os.path.join(h2o_java, "bin", java)
          if not os.path.exists(full_path):
              raise H2OStartupError(
                  "Environment variable H2O_JAVA_HOME is set to '%d' "
                  "but this location doesn't appear to be a valid Java Home directory, "
                  "unset environment variable or provide valid path to Java Home."
                  % h2o_java
              )
          return full_path
  
      # is java callable directly (doesn't work on windows it seems)?
      if os.access(java, os.X_OK):
          return java
  
      # Can Java be found on the PATH?
      for path in os.getenv("PATH").split(
          os.pathsep
      ):  # not same as os.path.sep!
          full_path = os.path.join(path, java)
          if os.access(full_path, os.X_OK):
              return full_path
  
      # check if JAVA_HOME is set (for Windows)
      if os.getenv("JAVA_HOME"):
          full_path = os.path.join(os.getenv("JAVA_HOME"), "bin", java)
          if os.path.exists(full_path):
              return full_path
  
      # check "/Program Files" and "/Program Files (x86)" on Windows
      if sys.platform == "win32":
          # On Windows, backslash on the drive letter is necessary, otherwise os.path.join produces an invalid path
          program_folders = [
              os.path.join("C:\\", "Program Files", "Java"),
              os.path.join("C:\\", "Program Files (x86)", "Java"),
              os.path.join("C:\\", "ProgramData", "Oracle", "Java"),
          ]
          for folder in program_folders:
              for dirpath, dirnames, filenames in os.walk(folder):
                  if java in filenames:
                      return os.path.join(dirpath, java)
  
      # not found...
      raise H2OStartupError(
          "Cannot find Java. Please install the latest JRE from\n"
          "http://docs.h2o.ai/h2o/latest-stable/h2o-docs/welcome.html#java-requirements"
      )
  
imports: from h2o.utils.compatibility import *
  import atexit
  import os
  import subprocess
  import sys
  import tempfile
  import time
  import re
  from random import choice
  from sysconfig import get_config_var
  from warnings import warn
  from h2o.exceptions import H2OServerError, H2OStartupError, H2OValueError
  from h2o.utils.typechecks import assert_is_type, assert_satisfies, BoundInt, I, is_type
label_desc: Use image node_id 14 for calling the H2OLocalServer obj's underlying member method code with example usage: obj._find_java() and returns: full_path, java, full_path, full_path, os