You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/java_env.R
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -38,14 +38,13 @@ java_env_set <- function(
38
38
project_path=NULL,
39
39
quiet=FALSE
40
40
) {
41
-
rje_consent_check()
42
-
41
+
43
42
where<- match.arg(where)
44
43
checkmate::assertString(java_home)
45
44
checkmate::assertFlag(quiet)
46
-
47
-
48
-
45
+
46
+
47
+
49
48
if (where%in% c("session", "both")) {
50
49
java_env_set_session(java_home)
51
50
if (!quiet) {
@@ -55,7 +54,8 @@ java_env_set <- function(
55
54
))
56
55
}
57
56
}
58
-
57
+
58
+
rje_consent_check()
59
59
if (where%in% c("project", "both")) {
60
60
# consistent with renv behavior for using
61
61
# the current working directory by default
@@ -82,6 +82,14 @@ java_env_set <- function(
82
82
#' @keywords internal
83
83
#'
84
84
java_env_set_session<-function(java_home) {
85
+
86
+
# check if rJava is installed and alread initialized
87
+
if (requireNamespace("rJava", quietly=TRUE)) {
88
+
if( rJava:::.jniInitialized==TRUE ) {
89
+
cli::cli_inform(c("!"="You have already initialised `rJava` directly or via your Java-dependent R package in the current session. `Java` version can only be set once per session for packages that rely on `rJava`. Unless you restart the R session or run your code in a new R subprocess using `targets` or `callr`, the new `JAVA_HOME` and `PATH` will not take effect."))
0 commit comments