Open e-kotov opened 2 days ago
sw_vers
#> ProductName: macOS
#> ProductVersion: 14.5
#> BuildVersion: 23F79
uname -m
#> arm64
brew install --cask r
brew install --cask rstudio
which java
#> /usr/bin/java
java --version
#> The operation couldn't be completed. Unable to locate a Java Runtime.
#> Please visit http://www.java.com for information on installing Java.
{r5r}
and {remotes}
, then {rJavaEnv}install.packages(c("remotes","r5r"))
remotes::install_github("e-kotov/rJavaEnv")
library(rJavaEnv)
java_quick_install(21)
java_check_version_rjava()
library(r5r)
# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path)
# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))
departure_datetime <- as.POSIXct(
"13-05-2019 14:00:00",
format = "%d-%m-%Y %H:%M:%S"
)
ttm <- travel_time_matrix(
r5r_core,
origins = points,
destinations = points,
mode = c("WALK", "TRANSIT"),
departure_datetime = departure_datetime,
max_trip_duration = 60
)
head(ttm)
{rJavaEnv}
package works as expected. Even without any Java installed on vanilla system, the package is able to successfully install Java and set it up in the R project/working directory. The dependent package {r5r}
is able to run without any issues.
This is tested with CRAN version of R that downloads precompiled binaries of packages. If the {rJava}
package needs to be compiled from source (e.g. for R installed using brew install r
), it will require Java to be installed before installing {rJava}
and {r5r
} or other {rJava}
-dependent package.
sw_vers
#> ProductName: macOS
#> ProductVersion: 14.5
#> BuildVersion: 23F79
uname -m
#> arm64
brew install r
brew install --cask rstudio
which java
#> /usr/bin/java
java --version
#> The operation couldn't be completed. Unable to locate a Java Runtime.
#> Please visit http://www.java.com for information on installing Java.
rJava
} can be installed with Java installed using {rJavaEnv
}install.packages("remotes")
remotes::install_github("e-kotov/rJavaEnv")
library(rJavaEnv)
java_quick_install(21)
java_check_version_cmd()
install.packages("rJava")
results in:
configure: error: Java Development Kit (JDK) is missing or not registered in R Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package 'rJava'
* removing "/opt/homebrew/lib/R/4.4/site-library/rJava'
Warning in install.packages :
installation of package "rJava' had non-zero exit status
javareconf
export JAVA_HOME=/Users/user/Library/Caches/org.R-project.R/R/rJavaEnv/installed/macos/aarch64/21
R CMD javareconf -e
install.packages("rJava")
Fails.
export JAVA_HOME=/Users/user/Library/Caches/org.R-project.R/R/rJavaEnv/installed/macos/aarch64/21
R CMD javareconf
install.packages("rJava")
Succeeds! {rJava}
is built from source!
Overall, {rJavaEnv}
package works as expected, but some manual actions are still required from the user. Specifically, the user needs to close R/RStudio and run two commands in the terminal with admin privileges to reconfigure Java.
There is no official stable R or RStudio for Windows for ARM processors, so I am testing x64 R and RStudio in Windows for ARM preview with x64 emulation.
winver
#> Microsoft Windows
#> Version 23H2 (OS Build 22631,2861)
cmd c /ver
#> Microsoft Windows [Version 10.0.22631.2861]
systeminfo | findstr /C:"System Type"
#> System Type: ARM64-based PC
java --version
#>'java' is not recognized as an internal or external command,
operable program or batch file.
{r5r}
and {remotes}
, then {rJavaEnv}install.packages(c("remotes","r5r"))
remotes::install_github("e-kotov/rJavaEnv")
library(rJavaEnv)
java_quick_install(21)
java_check_version_rjava()
library(r5r)
# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path)
# load origin/destination points
points <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))
departure_datetime <- as.POSIXct(
"13-05-2019 14:00:00",
format = "%d-%m-%Y %H:%M:%S"
)
ttm <- travel_time_matrix(
r5r_core,
origins = points,
destinations = points,
mode = c("WALK", "TRANSIT"),
departure_datetime = departure_datetime,
max_trip_duration = 60
)
head(ttm)
{rJavaEnv}
package works as expected. Even without any Java installed on vanilla system, the package is able to successfully install Java and set it up in the R project/working directory. The dependent package {r5r}
is able to run without any issues.
{rJavaEnv}
is ready for use for an ordinary user who installs default R and RStudio using official installers for Windows, does not have any prior Java installed and does not need to build {rJava}
from source. And that is probably 99% of users.
This is tested with CRAN version of R that downloads precompiled binaries of packages. If the {rJava}
package needs to be compiled from source, it will require Java to be installed before installing {rJava}
and {r5r
} or other {rJava}
-dependent package. However, on Windows for a typical user this is not an issue.
Tested on Windows for ARM processors, but R and RStudio are running in x64 emulation/translation. Therefore, x64 is detected by {rJavaEnv}
and consequently x64 Java is downloaded and linked into the project/current directory and used by {r5r}
. I do not think that Java for Windows for ARM would work with x64 R. And there is no Java for Windows for ARM anyway (at least not of Amazon Corretto flavour).
Test
{rJavaEnv}
on vanilla systems running: