Skip to contents

This function sets the JAVA_HOME environment variable, initializes the JVM using rJava, and prints the Java version that would be used if the user sets the given JAVA_HOME in the current R session. This check is performed in a separate R session to avoid having to reload the current R session. The reason for this is that once Java is initialized in an R session, it cannot be uninitialized unless the current R session is restarted.

Usage

java_check_version_rjava(java_home = NULL, verbose = TRUE)

Arguments

java_home

The path to the desired JAVA_HOME. If NULL, uses the current JAVA_HOME environment variable.

verbose

Whether to print detailed messages. Defaults to TRUE.

Value

TRUE if successful, otherwise FALSE.

Examples

java_check_version_rjava()
#> Using current session's JAVA_HOME: /usr/lib/jvm/temurin-11-jdk-amd64
#> With the user-specified JAVA_HOME rJava and other rJava/Java-based packages
#> will use Java version: "11.0.23"
#> [1] TRUE