Skip to contents

Check installed Java version using terminal commands

Usage

java_check_version_cmd(java_home = NULL, quiet = FALSE)

Arguments

java_home

Path to Java home directory. If NULL, the function uses the JAVA_HOME environment variable.

quiet

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

Value

A character vector of length 1 containing the major Java version.

Examples

java_check_version_cmd()
#> JAVA_HOME: /usr/lib/jvm/temurin-11-jdk-amd64
#> Java path: /usr/bin/java
#> Java version: "openjdk version \"11.0.25\" 2024-10-15 OpenJDK Runtime
#> Environment Temurin-11.0.25+9 (build 11.0.25+9) OpenJDK 64-Bit Server VM
#> Temurin-11.0.25+9 (build 11.0.25+9, mixed mode)"
#> [1] "11"