'RStudio fatal error when loading tabulizer

I recently updated R to version 4.2.0 on my Windows 10 PC. When I try to load the package tabulizer, RStudio crashes and the bomb icon with the correspondent "R encountered a fatal error" appears. I reinstalled rJava, tabulizer and tabulizerjar following the GitHub Repo. This is, using the following command line:

remotes::install_github(c("ropensci/tabulizerjars", "ropensci/tabulizer"), INSTALL_opts = "--no-multiarch")

In addition, I set manually the JAVA_HOME from my environment variables and used the command Sys.setenv(JAVA_HOME = "C:/Program Files/Java/jdk-18.0.1"). As you may notice, I used the last JDK version available here.

This strategy worked on VSCode and in R-Terminal if I used the following:

Sys.setenv(JAVA_HOME = "C:/Program Files/Java/jdk-18.0.1")
library(tabulizer)

However, I could not make it work on RStudio (version 2022.02.1 Build 461).

I left my R Session for further reference:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Mexico.utf8  LC_CTYPE=Spanish_Mexico.utf8    LC_MONETARY=Spanish_Mexico.utf8 LC_NUMERIC=C                   
[5] LC_TIME=Spanish_Mexico.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rJava_1.0-6

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0  


Solution 1:[1]

I had the same issue with RStudio while R worked just fine. I eventually got it work by installing R version 4.1.3. Believe there are issues caused this in the latest release, i.e. version 4.2.0.

Solution 2:[2]

Same issue with package xlsx (which also relies on rJava). I still use jdk-17.0.3, but identical behavio(u)r.

Reproduce (minimal):

library(rJava)
.jinit()

Session info:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] LC_COLLATE=English_Belgium.utf8  LC_CTYPE=English_Belgium.utf8    LC_MONETARY=English_Belgium.utf8
[4] LC_NUMERIC=C                     LC_TIME=English_Belgium.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rJava_1.0-6

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0   

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rebecca
Solution 2 Jan Doornaert