This method assembles the command used to start a Java worker.

    Args:
        java_worker_options (str): The command options for Java worker.
        redis_address (str): Redis address of GCS.
        plasma_store_name (str): The name of the plasma store socket to connect
           to.
        raylet_name (str): The name of the raylet socket to create.
        redis_password (str): The password of connect to redis.
        temp_dir (str): The path of the temporary directory Ray will use.
    Returns:
        The command string for starting Java worker.

def build_java_worker_command(
        java_worker_options,
        redis_address,
        plasma_store_name,
        raylet_name,
        redis_password,
        temp_dir,
):
    """This method assembles the command used to start a Java worker.

    Args:
        java_worker_options (str): The command options for Java worker.
        redis_address (str): Redis address of GCS.
        plasma_store_name (str): The name of the plasma store socket to connect
           to.
        raylet_name (str): The name of the raylet socket to create.
        redis_password (str): The password of connect to redis.
        temp_dir (str): The path of the temporary directory Ray will use.
    Returns:
        The command string for starting Java worker.
    """
    assert java_worker_options is not None

    command = "java ".format(java_worker_options)
    if redis_address is not None:
        command += "-Dray.redis.address={} ".format(redis_address)

    if plasma_store_name is not None:
        command += (
            "-Dray.object-store.socket-name={} ".format(plasma_store_name))

    if raylet_name is not None:
        command += "-Dray.raylet.socket-name={} ".format(raylet_name)

    if redis_password is not None:
        command += "-Dray.redis.password={} ".format(redis_password)

    command += "-Dray.home={} ".format(RAY_HOME)
    # TODO(suquark): We should use temp_dir as the input of a java worker.
    command += "-Dray.log-dir={} ".format(os.path.join(temp_dir, "sockets"))

    if java_worker_options:
        # Put `java_worker_options` in the last, so it can overwrite the
        # above options.
        command += java_worker_options + " "
    command += "org.ray.runtime.runner.worker.DefaultWorker"

    return command