Depends a bit on how you've installed java (package manager vs. direct download)
1. Terminal
# Homebrew
brew info openjdk
ls /opt/homebrew/opt/openjdk # expected installation location
brew --prefix openjdk # prints actual installation path (should be /opt/homebrew/opt/openjdk)
brew list | grep openjdk
# Look for installs on computer
/usr/libexec/java_home -V # list all java installs on computer
# R CMD javareconf # R reconfiguration
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home # output either from /usr/libexec/java_home -V or brew --prefix openjdk
sudo R CMD javareconf # R reconfiguration with admin privileges
2. R
# Then restart R session!
install.packages("rJava") # should work now
Depends a bit on how you've installed java (package manager vs. direct download)
1. Terminal
2. R