在控制台中使用R进行一些练习之后,我尝试将其连接到我的IDE(NetBeans)。因此,我下载并安装了“ rJava”,但是经过一些尝试,我遇到了IDE看不到库“ jri.dll”的问题,尽管它位于Java路径中。其他代码输出将看到此文件。
NetBeand IDE,Windows 7,Java 8、64x,PATH = -Djava.library.path =“ C:\ Program Files \ R \ R-3.5.3 \ library \ rJava \ jri \ x64”,项目中的库-JRI,TestR,TestConsole,路径包含jri.dll,R.dll,Rblas.dll,Rgraphapp.dll,Riconv.dll,Rlapack.dll
public class Jri {
public static void main(String[] args) {
String[] paths = System.getProperty("java.library.path").split(";");
for (String path : paths) {
File file = new File(path + "/jri.dll");
System.out.printf("file: %s exists: %s%n", file, file.exists());
}
System.loadLibrary("jri.dll");
}
}
2。
public class TestR {
public static void main(String args[]) {
Runtime.getRuntime().loadLibrary("jri");
System.out.println("Library Loaded.");
if (!Rengine.versionCheck()) {
System.err.println("Java version mismatch.");
System.exit(1);
}
String my[] = {"--vanilla"};
Rengine re = new Rengine(my, false, new TextConsole());
if (!re.waitForR()) {
System.out.println("Cannot load R");
System.exit(1);
}
REXP result = re.eval("mean(1:6)");
System.out.println("rexp: " + result.asDouble());
}
}
file: C:\Program Files\R\R-3.5.3\library\rJava\jri\x64\jri.dll exists: true
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jri.dll in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at testr.Jri.main(Jri.java:24)
C:\Users\KSmirnov\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\R\R-3.5.3\library\rJava\jri\x64\jri.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.Runtime.loadLibrary(Runtime.java:858)
at testr.TestR.main(TestR.java:18)
C:\Users\KSmirnov\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
我如何使其起作用? 预先感谢。