R/get_default_java_path.R

Defines functions get_default_java_path

Documented in get_default_java_path

#' Obtains the default path to the Java executable
#' @inheritParams default_params_doc
#' @return the default path to the Java executable
#' @author Richèl J.C. Bilderbeek
#' @export
get_default_java_path <- function(
  os = rappdirs::app_dir()$os
) {
  check_os(os)
  rJava::.jinit()
  java_folder <- rJava::.jcall(
    "java/lang/System", "S", "getProperty", "java.home"
  )
  check_true(dir.exists(java_folder))
  java_path <- file.path(java_folder, "bin", "java.exe")
  if (os != "win") {
    java_path <- file.path(java_folder, "bin", "java")
  }
  check_true(file.exists(java_path))
  normalizePath(java_path, mustWork = TRUE)
}

Try the beastier package in your browser

Any scripts or data that you put into this service are public.

beastier documentation built on Nov. 7, 2023, 5:08 p.m.