本文介绍了在Windows上设置Java R接口(JRI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经关注了网络上的指南并查看了有关stackoverflow的问题,但我仍无法在Windows上设置JRI。

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.

以下是我的步骤采取:

1)安装R

2)执行 install.packages( r中的rJava)安装rJava

2) Execute install.packages("rJava") in R to install rJava

3)创建 R_HOME 系统变量值 C:\Program Files \R\R-3.1.2

3) Create a R_HOME system variable with value C:\Program Files\R\R-3.1.2

4)添加跟随我的 PATH 变量: C:\Program Files \R\R-3.1.2 \ bin \ x64; C: \ Users\USERNAME \Documents\R\win-library\3.1\rJava \ jri \ x64

4) Add the following to my PATH variable: C:\Program Files\R\R-3.1.2\bin\x64;C:\Users\USERNAME\Documents\R\win-library\3.1\rJava\jri\x64

5)添加了JRI.jar(位于 C:\ Users \USERNAME \Documents\R\win-library\3.1\rJava \ jri )作为IntelliJ中的依赖项

5) Added the JRI.jar (located in C:\Users\USERNAME\Documents\R\win-library\3.1\rJava\jri) as a dependency in IntelliJ

6)将IntelliJ中的VM选项设置为 -Djava.library.path = C:\ Users \USERNAME\Documents\\ R\win-library\3.1\rJava \ jri \ x64

6) Set the VM options in IntelliJ to -Djava.library.path=C:\Users\USERNAME\Documents\R\win-library\3.1\rJava\jri\x64

7)启动R并执行 library(rJava)

8)运行我的程序来测试是否所有内容都已设置

8) Run my program to test if everything is set up

获取以下错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006c726096, pid=5860, tid=6932
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 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\USERNAME\Documents\Project\hs_err_pid5860.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

如果我删除VM选项以便java.library.path不是指定然后我收到以下错误:

If I remove the VM option so that java.library.path isn't specified then I get the following error:

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:1865)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
    at com.coagsm.cs.fyp.Test.<clinit>(Test.java:11)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:260)


推荐答案

如何实例化Rengine?

How you instantiating Rengine?

它应该是这样的:

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

其中,args可以来自你的main方法。

where, the args could be from your main method.

如果有效,请告诉我!

这篇关于在Windows上设置Java R接口(JRI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 09:05