R Fix Error in Loading “xlsx” Package

read.xlsx () in “xlsx” package is a simple function that reads a sheet in .xlsx file.
In Windows, however, you need to do some set-up before using this function if you get this error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : java.lang.OutOfMemoryError: Java heap space

When you get this error, put this one line before loading “xlsx” package.

#### Set-Up #### 
options(java.parameters = "-Xmx1000m")
################

# For those who get an error when loading "xlsx" pacakge
if (Sys.getenv("JAVA_HOME")!="") {
 Sys.setenv(JAVA_HOME="")
}

library ("xlsx")

Now, you can enjoy read.xslx ()!

Leave a comment