Renv and Java: "Error in rJava::.jinit() : Unable to create a Java class loader"

583 views Asked by At

I have a script that works perfectly when I'm not using Renv. However, when running it in a project with Renv enabled, the last command line returns the following message:

> r5r_core <- setup_r5(data_path = data_path, verbose = FALSE)
Error in rJava::.jinit() : Unable to create a Java class loader.

Just run the code below inside a renv project to have a reproducible example:

options(java.parameters = "-Xmx2G")
library(r5r)
library(rJava)

data_path <- system.file("extdata/poa", package = "r5r")
list.files(data_path)

poi <- fread(file.path(data_path, "poa_points_of_interest.csv"))
head(poi)

points <- fread(file.path(data_path, "poa_hexgrid.csv"))
points <- points[ c(sample(1:nrow(points), 10, replace=TRUE)), ]
head(points)

# Indicate the path where OSM and GTFS data are stored
r5r_core <- setup_r5(data_path = data_path, verbose = FALSE)

My Java version is compatible with the one used in this package, but it looks like R is having a hard time communicating with Java in Renv. Could anyone tell me?

0

There are 0 answers