3
votes

yesterday we migrated to windows 7 in our firm and also updated the java packages and also R (to 2.14).

Then I tried to load the xlsx package, because I rely heavly on it but i get the following error:

Error : .onAttach in attachNamespace()
Error: .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")

I tried the following, but it did not work:

Sys.setenv(PATH=paste(Sys.getenv("PATH"),"C:\\Program Files (x86)\\Java\\jre6\\bin\\client",collapse=';')) 
options(java.parameters = "-Xmx1000m")

Since I never work with java i have no clue what I can do. Can you help me?

Thank you!

sessionInfo() R version 2.14.1 (2011-12-22) Platform: i386-pc-mingw32/i386 (32-bit)

locale: [1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C
[5] LC_TIME=German_Austria.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] xlsxjars_0.4.0 rJava_0.9-3

loaded via a namespace (and not attached): [1] tools_2.14.1 xlsx_0.4.2


The interesting thing is, that the package XLConnect loads without problems.EDIT: Ok, it loads without problems but loading a workbook does not work:

Error: NoSuchMethodError (Java): org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions;

So maybe it is really no Java problem. But I don't want to re-write all my code to XLConnect!

Nobody any ideas what I could try?

1
Try loading rJava package only. Is your R 32-bit or 64? I had a similar type of problem and that was because I had installed only 32-bit Java, not 64 (that you'll have to install manually)Mikko
Loading rJava works! I use R 32 bit, because I need to establish a odcb connection which only works with 32 bit.rainer
Ok, then it's probably not a Java error.Mikko
Right now I did set the path variable, but does not work either. Btw my windows 7 is 64bit versionrainer
xlsx loads for me on both 32 bit and 64 bit R 2.15.0 in Windows 7. Are you able to try installing R 2.15.0?jthetzel

1 Answers

4
votes

I encountered exactly the same error and found a work-around. If you specify a library location on the network to install the package into, the error occurs.

## Example where error occurs: 
install.packages('xlsx', lib='\\network\R\library')
library('xlsx', lib='\\network\R\library'))

However, if you change the default location for package installation within R, then you should be able to call the package library without the error. That is, simply typing install.packages('xlsx'), and having the package install automatically to its default location, allowed the package to work properly.