JRI return code 10

I am new to R and was trying to call a simple rJava test program from java. I made the necessary path settings and when I try to instantiate Rengine the code is not working. The problem seems to be related to C [R.dll + 0x26036] . However, I am new to this and cannot figure out this issue. Any help would be greatly appreciated.

My code:

import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
public class First_R {
public static void main (String args []) {

    System.out.println("Start");
    Rengine.DEBUG = 5;

    System.out.println("Starting Rengine..");
    System.out.println("R_HOME =" + System.getenv("R_HOME"));
    final Rengine re = new Rengine ();
    // Check if the session is working.
    if (!re.waitForR()) {
        return;
    }
    re.assign("x", new double[] {1.5, 2.5, 3.5});
    REXP result = re.eval("(sum(x))");
    System.out.println(result.asDouble());
    re.end();
}

      

}

Output:

Start Launch Rengine .. R_HOME = D: \ Program Files \ R \ R-3.2.0 \ bin \

Fatal error encountered in Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc = 0x000000006c726036, pid = 4588, tid = 1872

JRE version: Java (TM) SE (8.0_45-b14) (build 1.8.0_45-b14) Java VM: Java HotSpot (TM) 64-bit server VM (25.45-b02 mixed mode windows-amd64 compressed oops)   Problematic frame: C [R.dll + 0x26036]

Failed to write main dump. Minidumps are not enabled by default on client versions of Windows

The error message file with additional information is saved as:

+3


source to share


2 answers


In your environment settings change R_HOME to D:\Program Files\R\R-3.2.0

instead of R_HOME = D:\Program Files\R\R-3.2.0\bin\

, let me know if that does the job :), note that your code works for me (via nicola advice)

package rundavid;

import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;



public class RunDavid {


public static void main (String args []) {



    System.out.println("R_HOME =" + System.getenv("R_HOME"));


    Rengine re = new Rengine (new String [] {"--vanilla"}, false, null);
    // Check if the session is working.
    if (!re.waitForR()) {
        return;
    }
    re.assign("x", new double[] {1.5, 2.5, 3.5});
    REXP result = re.eval("(sum(x))");
    System.out.println(result.asDouble());
    re.end();
}}

      

output:



run:
R_HOME =C:\Program Files\R\R-2.15.3
7.5
BUILD SUCCESSFUL (total time: 0 seconds)

      

Also you need to configure D:\Program Files\R\R-3.2.0\bin\x64;D:\Misc\RLib\rJava\jri\x64

This needs to be configured in the vm options, not as an environment variable. this is how it is done in Netbeans

(what it uses):

  • Right click on the project then click on properties
  • Then select run

  • Paste the parameters of the virtual machine in the following order: How to set VM options in Net beans
+2


source


You must initialize yours correctly Rengine

. Try the following:

Rengine re = new Rengine (new String [] {"--vanilla"}, false, null);

      



when you build the engine and everything should work. The no-argument constructor "creates a new mechanism by connecting to an existing initialized R instance that calls this constructor" (from doc ). This throws an error since no existing one Rengine

works (I think).

+1


source







All Articles