Setting up Java R Interface (JRI) on Windows

前端 未结 2 1154
旧巷少年郎
旧巷少年郎 2020-12-18 11:15

I have followed guides on the web and looked at questions on stackoverflow but I am still not able to set up JRI on Windows.

Here are the steps I have taken:

相关标签:
2条回答
  • 2020-12-18 11:39

    Latest (2018) for me was to do this :-

    export R_HOME=$(R RHOME)
    

    Then compile this:-

    String[] enginargs = {"--no-save"};
    REngine engine = org.rosuda.REngine.JRI.JRIEngine.createEngine(enginargs, null, false);
    
    try {
        engine.parseAndEval("print(\"Hello from R\");");
    }
    catch(Exception e ) {
        System.err.println("OOps:-" + e.getMessage());
    }
    finally {
        engine.close();
    }
    

    Then when running the java either set the LD_LIBRARY_PATH to enclude JRI or set the -Djava.library.path eg

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/R/site-library/rJava/jri/
    

    or

    java -Djava.library.path=/usr/local/lib/R/site-library/rJava/jri/ MyMainClass
    
    0 讨论(0)
  • 2020-12-18 11:44

    How you instantiating Rengine?

    It should be something like this:

    Rengine rengine = new Rengine(args, false, null);

    where, the args could be from your main method.

    Let me know if this works!

    0 讨论(0)
提交回复
热议问题