Skip to main content

detect_java_version

Function detect_java_version 

Source
pub fn detect_java_version() -> Result<String, JavaError>
Expand description

Detect the installed Java major version by running javac -version.

javac (not java) is used because the compiler determines what class-file format is produced; the runtime is not guaranteed to be present. Output is read from stdout (most JDKs) with stderr as fallback.

§Errors

Returns JavaError::Io if javac cannot be spawned or its output cannot be parsed as a version string.