Java calls the installation and configuration of R--rjava

Source: Internet
Author: User

Rjava is the package that Java calls R to install through Jri. Configuration is more troublesome, I refer to the network configuration, using Rjava Package example inside the sample test, console display:

Cannot find Jri native library! Sure the Jri native library is in a directory listed in Java.library.path.

Java.lang.unsatisfiedlinkerror:d:\developmenttools\r-3.1.1\library\rjava\jri\jri.dll:can ' t load IA 32-bit. dll on a AMD 64-bit Platform

This means that the JVM cannot load a 32-bit. dll file. I changed it over and over again and finally succeeded after many attempts. Here's how I installed and configured.

1. Download Rjava.

Downloading and installing Rjava is simple, just need to enter install.packages ("Rjava") in R, then select the image you want to install. Such as:

  

I chose China (Beijing 2). When selected, it is automatically installed.

After the download is completed, there will be a Rjava directory in the library directory of the R home directory, which is the Rjava package that you just downloaded.

2. Configure Environment variables:

First, the new system variable name is R_home, the variable value is the home directory where R is installed, such as my: D:\developmentTools\R-3.1.1, which needs to be modified according to its own directory. Then add the%r_home%\library\rjava\jri\jri.jar directly in the CLASSPATH variable; Note that multiple variables are separated by semicolons, and the following steps are critical. Include both 32-bit and 64-bit files in the downloaded Rjava package, depending on whether your JVM is 32-bit or 64-bit. Such as:

  

The Jri folder has i386 (for 32-bit) and x64 (for 64-bit) two folders, each with 32-bit and 64-bit jri.dll. Jri folder also has jri.dll this file, but its default is 32 bit (can be based on size, 64 bit larger), if your JVM is 64 bits, you need to use the x64 folder with the same name file to replace it. My JVM is 64-bit, many on the internet are in 32-bit terms, so I have not been successful. Succeeded after the substitution. Then configure the path variable and add it to the PATH variable:%r_home%\bin\x64;%r_home%\library\rjava\jri;. (If your JVM is 32-bit, x64 change to i386)

3. Test.

You can use the samples in the Rjava package to test, note to add Jri.jar, Jriengine.jar, Rengine.jar three package files.

  

  

    

Java calls the installation and configuration of R--rjava

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.