OHDSI / CirceR

R package wrapper for CIRCE
https://ohdsi.github.io/CirceR/
6 stars 2 forks source link

Configuring Locale for the JVM #24

Closed anthonysena closed 1 year ago

anthonysena commented 1 year ago

I'm making a note of this for posterity based on my work on OHDSI/circe-be#184. I made an attempt to force the JVM to initialize to a specific location/language using the following change:

Current Code:

https://github.com/OHDSI/CirceR/blob/38bf8b44d87f759dd4ba36835ce30627b3c24e6b/R/CirceR.R#L24-L26

My approach:

.onLoad <- function(libname, pkgname) {
  options(java.parameters = c("-Duser.country=US", "-Duser.language=en"))
  rJava::.jpackage(pkgname, lib.loc = libname)
}

Unfortunately, setting the options as I have done above only works if the JVM has not been initialized already by another process. In that case, whatever process initialized the process wins and will use the user's default locale information. As a result, I had to make the changes for OHDSI/circe-be#184 directly in the circe-be library. I just wanted to note this failed solution in case others are thinking of trying to force the locale through rJava.