Problem: Trying to call library(“xlsx”) throws error message indicating that JDK path cannot be found, but you have Java already installed. Your version is more recent than what the package is expecting. You attempt to update your system/IDE so that calls for JDK now point to the newer version
$ sudo R CMD javareconf
— but you get the following error message
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Issue: (1) Many IDEs and programming language packages rely on differing developer versions than might be installed on your OS. For example, if you upgraded your Java from 9 to 10, and an R-package (such as ‘rJava’ or ‘XLSX’) was built so as to specifically call on directories with the name “/Library/Java/JavaVirtualMachines/jdk-9.jdk/”. (2) You must have:
- install_name_tool
- This requires Command Line Tools for Xcode installed/downloaded from Apple
Solution:
- Ensure you have Java (jdk) installed.
$ java -version
- Ensure you have Command Line Tools for Xcode — https://developer.apple.com/download/more/
- Reconfigure R to look at newer jdk locations when asked for older versions. RUN the following command line:
$ sudo R CMD javareconf
- QUIT & RESTART RStudio