Temporarily sets JAVA_HOME and PATH for the duration of the provided
code block, then restores the previous environment.
Arguments
- version
Integer or character. Required. The Java version you need (e.g., 17, 21). Defaults to
NULL, which is invalid and will trigger a validation error; callers should always provide a non-NULLvalue explicitly.- code
The code to execute with the temporary Java environment.
- ...
Additional arguments passed to
local_java_env().
Warning - Not for rJava
Do not use this function if your package depends on rJava.
See local_java_env() for details on why rJava is incompatible with scoped Java switching.
