Search code examples
rxlsxrjava

rJava library not working. Unable to find jvm.dll


I realize this question has been asked before but none of the solutions worked for me.

After a 'successful' install of rJava I try library(rJava) I receive an error that R cannot find jvm.dll. Here are the solutions I've tried:

  • Setting my PATH to include a direct link to the jvm.dll directory. Also tried one level up
  • Clearing the JAVA_HOME environmental variable. Also setting JAVA_HOME to the directory of my jvm.dll
  • Direct install from rforge.net using install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/'). I receive this error:

    Find Java... ERROR: cannot find Java Development Kit. Please set JAVA_HOME to specify its location manually

  • Attempted setting the path of JAVA_HOME using this command: options(java.home="C:\\Program Files (x86)\\Java\\jre1.8.0_121\\bin\\client")

Other potentially useful information:

  • Going into cmd and running echo %JAVA_HOME% shows the correct directory
  • I restarted RStudio after every attempt
  • Running on Windows 7 64 bit.

Any ideas would be greatly appreciated. Getting really frustrated trying to get this library working as it's needed for the xlsx library.

SOLUTION:

Egg on my face, the issue was that I accidentally pointed to environmental variable to an old 32 bit install of Java that I must have accidentally installed at some point in the last few years (thank you @user20650). Pointing everything back at the 64 bit version fixed things. For the record I did have to set JAVA_HOME to point to the correct directory. Also, make sure you have both the java JRE and JDK.


Solution

  • Egg on my face, the issue was that I accidentally pointed to environmental variable to an old 32 bit install of Java that I must have accidentally installed at some point in the last few years (thank you @user20650). Pointing everything back at the 64 bit version (ie C:\Program Files\Java\jdk1.8.0_121) fixed things after running install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/').

    For the record I did have to set JAVA_HOME to point to the correct directory. Also, make sure you have both the java JRE and JDK. Also, for some reason my anti-virus did not like letting that rforge install go through (didnt like the findjava.exe), so I had to pause it for a moment.