EXCEPTION_ACCESS_VIOLATION when trying to use RJava

653 views Asked by At

So I'm trying to make use of R from Java through JRI. I'm using the RJava plugin for Eclipse and the two test files which come with rJava are working fine (rtest and rtest2). But when trying to run this simple code fragment, I get an EXCEPTION_ACCESS_VIOLATION:

public static void main(String... args) {
    Rengine re = new Rengine();

    if (!re.waitForR()) {
        System.out.println("Unable to load R");
        return;
    } else
        System.out.println("Connected to R");

    re.eval("x=c(1:10)");
    double d = re.eval("mean(x)").asDouble();
    System.out.println(d);
}

The output I'm getting:

    Connected to R

A fatal error has been detected by the Java Runtime Environment:

 EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006c726096, pid=5284, tid=7868

JRE version: Java(TM) SE Runtime Environment (8.0_25-b18) (build 1.8.0_25-b18)
Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode windows-amd64 compressed oops)
Problematic frame:
C  [R.dll+0x26096]

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

An error report file with more information is saved as:
C:\Users\gebruiker\workspace64\RTest\hs_err_pid5284.log

If you would like to submit a bug report, please visit:
  http://bugreport.sun.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

The complete log: http://pastebin.com/18wHWihB

I'm seeing this in the log, does it have to do something with it? (wrong use of the eval function? I just copied an example though...)

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.rosuda.JRI.Rengine.rniParse(Ljava/lang/String;I)J+0
j  org.rosuda.JRI.Rengine.eval(Ljava/lang/String;Z)Lorg/rosuda/JRI/REXP;+53
j  org.rosuda.JRI.Rengine.eval(Ljava/lang/String;)Lorg/rosuda/JRI/REXP;+3
j  Main.main([Ljava/lang/String;)V+35
v  ~StubRoutines::call_stub

If anybody could help, I'm at a loss and would appreciate it greatly :)

2

There are 2 answers

0
Kishore Kanumalla On BEST ANSWER

Instanitiate rengine like below, i have just made 10 as default size.

String args1[] = new String[10];
Rengine rengine = new Rengine(args, false, null);
0
lagrelax On

You have to set the environment variable R_HOMEin your JVM environment. Set it in your environment variable won't work, JVM is NOT ware of that. Just figured it out by myself.