Answered By: Kristin Yeager Last Updated: Aug 15, 2016 Views: 546
Some R packages depend on Java (via the R package rJava) in order to function. This includes the packages xlsx and XLConnect, which are used to read from and write to Excel files in R. If you have installed either package and are getting an error message about JAVA_HOME when trying to load the package:
Windows users: You may need to update your version of Java, or you may need check that your version of Java has the same "bitness" (32-bit or 64-bit) as your version of R.
Mac users: Macs do not have Java installed by default, so you will need to download and install Java. (You do not have to have Excel installed in order to read and write to Excel files in R.) Your version of Java must match the "bitness" (32-bit or 64-bit) as your version of R.
- OS X 10.11 (El Capitan): You may need to install a legacy version of Java (Java SE 6) in order to use certain packages. You can download this legacy version from Apple's website directly.
All users who need to install Java can download it from java.com.
Users troubleshooting this issue in R can find helpful information at the following links:
Users who need to read Excel files into R (*.xls or *.xlsx) can also try the readxl package, which does not have any external dependencies; however, this package can not write data to Excel files as of this writing (August 2016).