Reputation: 3029
I am trying to setup a Java project on a Windows computer that invokes R code using rJava/JRI. I have installed JDK 1.8
, R 3.5.3
and rJava
library in R on my computer. I have added the following to my Path
variable: D:\Program Files\R\R-3.5.3\bin\x64; D:\Program Files\R\R-3.5.3\library\rJava\jri\x64
. I have also configured the Build Path in Eclipse by adding the three JAR files from the jri folder as external JARs and by changing the native library to D:/Program Files/R/R-3.5.3/library/rJava/jri/x64
. These are the same steps that I've recently done on another Windows computer and afterwards the R test script worked perfectly. However, on my current computer I keep getting the following message:
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: D:\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(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
at rtest.main(rtest.java:61)
Any idea what's going wrong? I would be really greatful for any help.
EDIT: Here is what my Build Path looks like:
EDIT2: Additionally, I have now copied all .DLL
files from D:\Program Files\R\R-3.5.3\bin\x64
together with jri.dll
to D:\Program Files\Java\jdk1.8.0_201\bin
as recommended here. Still no luck.
Upvotes: 4
Views: 6031
Reputation: 21
I resolved this after coming across this bug report: https://www.mail-archive.com/[email protected]/msg22016.html "As previously mentioned, the above exception is not thrown on machines where the Visual C++ 2019 redistributable is installed."
I downloaded the MS Visual C++ redistributable for 2015-2019 and installed it on two different computers with diff combinations of offAdoptJDK, jre_8u_202, and jre_8u_265, and this resolved my issue.
I downloaded the redistributable from the link below: https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
For Windows 10, I installed "x64: vc_redist.x64.exe" above and then my program ran successfully.
Upvotes: 0
Reputation: 1151
Please try this one:
Run As -> Run Configuration -> Set Environment Variables ->New
Name : PATH
Value: C:\Program Files\R\R-3.6.1\bin\x64;C:\Users\[Username]\Documents\R\win-library\3.6\rJava\jri\x64;
Upvotes: 3
Reputation: 3029
Ok, I got it. After having done everything that is listed in the first post, I also copied all .DLL
files from D:\Program Files\R\R-3.5.3\bin\x64
together with jri.dll
from D:\Program Files\R\R-3.5.3\library\rJava\jri\x64
to D:\Program Files\Java\jre1.8.0_201\bin
(in addition to the JDK
folder). Now the test script works. Thanks to everyone who tried to help!
Upvotes: 1
Reputation: 62
Try this:
project > Java Build Path
(here you can look your
libraries and import libraries)eclipse.ini
and check than your JDK is correctly linkedUpvotes: 0