28 responses to “Talking R through Java”

  1. greetings, I have a problem big problem, when I try to execute those steps, all work fine until the IDE configuration, I explain me better, I had installed Rjava, I had copied JAR requested, I had updated the environment variables in /etc/environment and until there all works configurate correctly, I work in Netbeans but I didn’t know if I had to do any configuration in the IDE. Finally when I run the program, it appear this “cannot find system Renviron”. Really I had tried all the possible things but I couldn’t fix it. Sorry for my english, and I will appreciate any help that you can give to me for understand why is the reason of my problem. Thanks

  2. Really, thank you so much for your help, it will be so useful, now I will follow with my project.

  3. Greetings,
    Now my Java-R connection works, I can make some calculus. But I do not know how I can use R’s libraries like RODBC through Java, I tried with: re.eval("library(RODBC)"), that did not work. Can you help me to use this library? How can I test the library is actually loaded?
    Thanks

  4. Greetings,

    I am trying to use JRI to programming JAve with R. I am testing a simple program but i have a problem with the REngine constructor. The program exit with the value 10, without exception. I have followed the steps before but i cant fix the problem.

    Thanks.

  5. Is it possible to invoke r functions or embedding r charts inside jasper’s ireport

  6. It really help. Thank you so much.

  7. hi,
    i hv the problem for runing this
    what mean Export the variable before starting Netbeans:

    1
    2
    usr@srv $ export R_HOME=/usr/lib64/R
    usr@srv $ netbeans

    write at where?

    actually my task is to write a java programing that will produce few value. Then i need to pass that value to R. then R will do some process eg sum the value with one. last pass it back to java. How can it work???

  8. The reply is late. I am trying to investigate the best way to run simulations on my socket server with varying distributions of bytes. It looks like r-java can do it instead of expensive load runners.

    Do you know of anyone who is doing it ?I asked the r-help list but they disregard generic questions like this.

  9. Dear George,
    The post of Using JRI , R with NetBeans in Windows was an excellent guide. I am using Eclipse IDE and trying to call R via a Java program using JRI.
    I have gone through your post and tried to replicate the same thing in Eclipse IDE. I am yet to get a successful output out of the java program (TestR.java). Here is what I did:
    1. Set R_Home variable => R_HOME = D:\Program Files\R\R-2.14.0
    2. Set PATH variable => PATH = D:\Program Files\R\R-2.14.0\bin\x64;(contains R.dll) D:\Program Files\R\R-2.14.0\library\rJava\jri; (containsJRI.dll,JRI.jar,JRIEngine, REngine), D:\Program Files\R\R-2.14.0\library\rJava\jri\x64 (contains JRI.dll)
    3. Added -Djava.library.path=D:\Program Files\R\R-2.14.0\library\rJava\jri\ to the VM arguments, and I executed the program and it gave the following error:
    “Could not find the main class: Files\R\R-2.14.0\library\rJava\jri\. Program will exit. “

  10. Hi,
    is there a way to get error messages from R back?

    – CODE EXAMPLE:
    Rengine rEngine = new Rengine(new String [] {“–vanilla”}, false, null);
    rEngine.eval(“library(xts)”);
    rEngine.assign(“arrayValue”, DOUBLE DATA);
    rEngine.assign(“arrayDates”, DOUBLE DATA);
    rEngine.eval(“test = xts(arrayValue, order.by=arrayDates)”);

    The last statement not only takes 1 minute to run, it also seems to fail (no test variable is created)
    -> Is there a way to get some log information?

    Thank you and best regards!

  11. Hi,

    I’m trying to do this in DrJava but I believe I’m getting stuck with setting the R_HOME environmental variable in DrJava. Does anybody know how to do this?

    Thanks

  12. There’s an eclipse plugin that helps set up the R Java environment at http://www.studytrails.com/RJava-Eclipse-Plugin/.

  13. This is not working in my windows machine. It throws exception

    Cannot find JRI native library!
    Please make sure that the JRI native library is in a directory listed in java.library.path.

    java.lang.UnsatisfiedLinkError: no jri in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1030)
    at org.rosuda.JRI.Rengine.(Rengine.java:9)
    at com.test.maintest.main(maintest.java:9)

    How can i solve it.My R global path is also right.

  14. @Swarga Bera
    For windows operating system, I would suggest to check on the environment variable of the windows operating system.
    I believe there is something called PATH
    and jri.dll should be searchable by the environment variable.

    after changing the environment variable, do not forget to restart the machine.

  15. hello

    i m using this configuration but when i m launching R its stop immediatly with exit code 2

    i have set up -Djava.library.path correctly because before setup this, i have the error that jri.dll coulnd’nt be found.

    now have done this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Rengine.DEBUG = 5;

    System.out.println("Starting Rengine..");
    System.out.println("R_HOME =" + System.getenv("R_HOME"));
    System.out.println("java.library.path =" + System.getProperty("java.library.path"));
    Rengine re = new Rengine(new String[] { "--vanilla" }, false, null);
    if (!re.waitForR()) {
         System.out.println("Cannot load R");
         return;
    }

    and when i m running the programm, on line Rengine re = new Rengine(new String[] { "--vanilla" }, false, null);
    it stop with exit code 2, in the console outpu i have :

    1
    2
    3
    4
    Starting Rengine..
    R_HOME =D:\Users\pmancaux\Desktop\Dev\R\GNU_R\R-3.0.2\bin
    java.library.path =D:\Users\pmancaux\Desktop\Dev\R\GNU_R\R-3.0.2\library\rJava\jri
    Starting R...

    i don t find any solution on internet! please help me! thanks a lot

    Palex

    1. same problem as Palex here…. everything used to work perfectly fine and now application crashes when i set up the Rengine (Rengine re=new Rengine(args, false, new TextConsole()); but i’ve used all syntax possible…)

      no idea… its driving me nuts….

      any help is dearly appreciated.

    2. ok, me again, sorry for mass posting… i solved previous issue. I updated everything (JRI and R) and it worked. Updating only JRI won’t do the trick. Anyway….
      Cheers :)

Leave a Reply

authorship