Problem
When you try to load the 'rJava' package you get the error:
Error: .onLoad failed in loadNamespace() for 'rJava'
Solution
Their are a number of environment variables and paths that need to be set on your system, in order for the 'rJava' package
to load successfully.
You should check the following on Windows:
-
Make sure that the environment variable 'JAVA_HOME' is set properly and points to a 64-bit version jof Java(JDK or SE
Runtime). For 64-bit Revolution R you need to make sure that you have a 64-bit version of Java installed. -
Make sure that the Java 'CLASSPATH' variable is set properly.
For the 64-bit version of the JDK, this is typically set to something like the following(on Windows):
'C:\Program Files\Java\jdk1.7.0_02\jre\lib\ext' -
Check your system PATH settings. On Windows, goto 'Control Panel ---> System --> Advanced Settings ---> Environment Variables'.
Your path should include the directories: 'C:\Program Files\Java\jre6\bin\server' and 'C:\Revolution\R-Enterprise-7.3\R-3.1.1\bin\x64'. -
Make sure that the environment variables 'RPATH' and 'RHOME' are BOTH set and point to the directory:
'C:\Revolution\R-Enterprise-7.3\R-3.1.1\bin\x64'
The same settings are required on Linux, however the paths will be different:
-
CLASSPATH: /usr/java/jdk1.7.0_02/jre/lib/ext
-
RPATH and RHOME: /usr/lib64/Revo-7.3/R-3.1.1
On Linux, it is also recommended that you run the command :
R CMD javareconf
This will attempt to configure Java properly on your system for use with Revolution R Enterprise.
Note that if not ALL of the configuration settings are filled out after running 'R CMD javareconf', this usually means that rJava won't work and your Java installation/configuration is insufficient.