Skip to content

Commit

Permalink
using correct java version locally
Browse files Browse the repository at this point in the history
  • Loading branch information
dhersz committed Oct 11, 2024
1 parent 971c0e8 commit 7dd6869
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
source("renv/activate.R")

if (Sys.getenv("RUSER") == "DHERSZ") source("~/.Rprofile")

# rJavaEnv begin: Manage JAVA_HOME
if (dir.exists("rjavaenv")) {
platform <- list.files("rjavaenv")
arch <- list.files(file.path("rjavaenv", platform))
version <- "11"

rjavaenv_cache_dir <- tools::R_user_dir("rJavaEnv", "cache")

java_home_path <- file.path(
rjavaenv_cache_dir,
"installed",
platform, arch, version
)

Sys.setenv(JAVA_HOME = java_home_path)
old_path <- Sys.getenv('PATH') # rJavaEnv
new_path <- file.path(Sys.getenv('JAVA_HOME'), 'bin') # rJavaEnv
Sys.setenv(PATH = paste(new_path, old_path, sep = .Platform$path.sep)) # rJavaEnv
rm(old_path, new_path) # rJavaEnv
}
# rJavaEnv end: Manage JAVA_HOME
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ site_libs/
*.docx
/docx_en_freeze/
/docx_pt_freeze/
rjavaenv/

0 comments on commit 7dd6869

Please sign in to comment.