WikiPrint - from Polar Technologies

JRE Installation

Installation of the Java Platform, Standard Edition Runtime Environment (JRE), allows you to run Java programs on your PC and as you browse the Internet. The rJava package used by loadeR and loadeR.ECOMS packages needs JRE in order to use the powerful capabilities of the ?netCDF Java Library.

It is very likely that JRE is already installed on your computer, but just in case it is not, here are some instructions on how to get it.

Linux users

To find out if JRE is installed in your machine, and in negative case to get instructions on how to install it, please refer to ?this link

Windows / Mac users

Click on the link below to download the JRE installer and perform the installation procedure by keeping the default installer settings. For Windows users, please be sure that you have downloaded the 32-bit JRE installer as indicated below.

?JRE installer download link (version 7 update 60):

Installing the rJava package

?rJava is a R package providing a low-level interface to Java from R. If Java is installed and adequately configured in your computer, the rJava package will be automatically downloaded if not present when installing the loadR package, as any other package dependency. rJava can be also installed directly by:

> install.packages("rJava")  

Once rJava is installed, you may want to know the characteristics of the java version used by R:

> library(rJava)
> .jinit()
[1] 0
> .jcall("java/lang/System", "S", "getProperty", "java.vendor")
[1] "Oracle Corporation"
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.7.0-b147"
> .jcall("java/lang/System", "S", "getProperty", "os.arch")
[1] "x86"

Therefore, in principle you should not worry about this and could skip this section. But just in case something related to rJava goes wrong during the installation, please bear in mind the following information:


Linux users can alternatively use the apt-get choice from the terminal:

~$ apt-get install r-cran-rjava

(In case of doubts, there is a recent discussion on both choices ?at this link that you may find helpful).

You can also find useful information about the installation and configuration of openJDK in ?this thread of the Ubuntu forum.

Mac OS X

Mac OS X comes with Java pre-installed, but sometimes an old version (~1.6) is used by the system, even if a new version is installed as described in the previous section. In this case, the problem is changing the default Java version to be used by R (or RStudio) to a newer one. You can check the version which is used in an R session by

> library(rJava)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

If you are having problems to run R (or RStudio) with a newer installed Java version please take try again opening R (or RStudio) from the terminal (instead of directly clicking on the application icon). Take a look to the following link: ?

In some cases, after recompiling RJava (as user, or sudo) as explained in the previous instructions, the problem is fixed when opening R (or RStudio) from the terminal (instead of directly clicking on the application icon).

~$ R


~$ /Applications/

Take is also some useful information at the following link: ?


For Windows 7, you can find some quick advice on how to get up and running with R + rJava ?at this link

If an error likes this one appears on your R console:

Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Users/antonio/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 no es una aplicación Win32 válida.

Error : package 'rJava' could not be loaded

it can be due to a misconfiguration of JAVA_HOME environment variable.

Please check that the corresponfing value points to the correct Java version and bit architecture (32 or 64).

> Sys.getenv("JAVA_HOME")  

You can remove from system environment and restart R or remove from R sesssion:

> if (Sys.getenv("JAVA_HOME")!="")
+     Sys.setenv(JAVA_HOME="")

or you can force the JVM ():

> Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\jdk1.7.0\\jre")

and check which JVM is using rJava:

> .jcall("java/lang/System", "S", "getProperty", "java.vendor")
[1] "Oracle Corporation"
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.7.0-b147"
> .jcall("java/lang/System", "S", "getProperty", "os.arch")
[1] "x86"