Setting up Java R Interface (JRI) on Windows

心不动则不痛 提交于 2019-11-29 08:03:37

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!

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!