Skip to contents

Unpack Java distribution file into cache directory and link the installation into a project directory, optionally setting the JAVA_HOME and PATH environment variables to the Java version that was just installed.

Usage

java_install(
  java_distrib_path,
  project_path = NULL,
  distribution = NULL,
  backend = NULL,
  autoset_java_env = TRUE,
  quiet = FALSE,
  force = FALSE
)

Arguments

java_distrib_path

A character vector of length 1 containing the path to the Java distribution file.

project_path

A character vector of length 1 containing the project directory where Java should be installed. If not specified or NULL, defaults to the current working directory.

distribution

The Java distribution name (e.g., "Corretto", "Temurin"). If NULL, uses attributes from java_distrib_path or defaults to "unknown".

backend

The download backend used (e.g., "native", "sdkman"). If NULL, uses attributes from java_distrib_path or defaults to "unknown".

autoset_java_env

A logical indicating whether to set the JAVA_HOME and PATH environment variables to the installed Java directory. Defaults to TRUE.

quiet

A logical value indicating whether to suppress messages. Can be TRUE or FALSE.

force

A logical. Whether to overwrite an existing installation. Defaults to FALSE.

Value

The path to the installed Java directory.

Examples

if (FALSE) { # \dontrun{

# set cache dir to temporary directory
options(rJavaEnv.cache_path = tempdir())
# download, install and autoset environmnet variables for Java 17
java_17_distrib <- java_download(version = "17")
java_install(java_distrib_path = java_17_distrib, project_path = tempdir())
} # }