"Initialize R in Java Project"

NiUlNiUl Member Posts: 1 Contributor I
edited June 2019 in Help
Dear community,
I am struggeling to load a RapidMiner process containing an "Execute Script (R)" operator in my Java project. I have set up R in RapidMiner correctly and when I start the process directly from the RapidMiner GUI, it works. However, when I try to load the process in my Java project, I receive the following notification:

Jul 16, 2014 10:21:02 AM org.rosuda.JRI.Rengine <clinit>
INFO: Creating Connection to R...
Jul 16, 2014 10:21:02 AM org.rosuda.JRI.Rengine isJriLoaded
WARNING: Access on uninitialized Rengine!
Jul 16, 2014 10:21:02 AM org.rosuda.JRI.Rengine isJriLoaded
INFO: Engine ID: class org.rosuda.JRI.Rengine ClassLoader:PluginClassLoader ([file:/C:/Users/Uli/.RapidMiner5/managed/rmx_r-5.3.0.jar])
Jul 16, 2014 10:21:02 AM com.rapidminer.tools.r.JRIRSession initializeEngine
SEVERE: Could not initialize R via JRI. Reason: Library wasn't loaded.
Exception in thread "main" com.rapidminer.operator.OperatorException: Could not initiate session with native R. Try using server. Reason: Could not initialize R via JRI. Reason: Library wasn't loaded.
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:239)
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:196)
at com.rapidminer.operator.r.RScriptOperator.doWork(RScriptOperator.java:185)
at com.rapidminer.operator.Operator.execute(Operator.java:867)
at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:711)
at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:375)
at com.rapidminer.operator.Operator.execute(Operator.java:867)
at com.rapidminer.Process.run(Process.java:949)
at com.rapidminer.Process.run(Process.java:873)
at com.rapidminer.Process.run(Process.java:832)
at com.rapidminer.Process.run(Process.java:827)
at com.rapidminer.Process.run(Process.java:817)
at QualityAssessmentOfDerivedVariables.<init>(QualityAssessmentOfDerivedVariables.java:28)
at ExecuteRapidMinerProcess.main(ExecuteRapidMinerProcess.java:22)
Caused by: org.rosuda.REngine.REngineException: Could not initialize R via JRI. Reason: Library wasn't loaded.
at com.rapidminer.tools.r.JRIRSession.initializeEngine(JRIRSession.java:324)
at com.rapidminer.tools.r.JRIRSession.<init>(JRIRSession.java:78)
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:235)
... 14 more
Caused by: org.rosuda.REngine.REngineException: Library wasn't loaded.
at org.rosuda.JRI.JRIEngine.<init>(JRIEngine.java:221)
at com.rapidminer.tools.r.JRIRSession.initializeEngine(JRIRSession.java:320)
... 16 more
The message "Could not initialize R via JRI. Reason: Library wasn't loaded" lets me assume that I have to set the path to the RJava library manually. Is this true? If so, how do I do this? I am running Win8.1 with RapidMiner 5.3.013.

Thank you + kind regards,


  • Flos_Flos_ Member Posts: 7 Contributor II
    Hello Uli, hello community,

    I am using RapidMiner 5.3.015 on Windows 7 and I have the same problem.
    I would be very grateful, if someone (probably from the RapidMiner team) could tell me how to solve this problem or point me to a location where a solution is explained (I didn't find one so far).

    I guess I need to set an environment variable in my Java code before running the process?

    Kind regards,

  • Flos_Flos_ Member Posts: 7 Contributor II
    Hey guys,

    fortunately I was able to solve the problem myself (although it took me some time ...). There might be other (better?) solutions to this problem, but this is how it worked for me:

    When using the Rapidminer-API within your own Java-Code it is necessary to call  

    to initialize Rapidminer before using it. When Rapidminer performs its initialization process it also sets all its environment variables. Usually the variable defining the location of the jri.dll should be initialized from the rapidminerrc file. In my case the GUI seems to use some rapidminerrc file in my User directory which is (with my configuration) not used when starting from my own java project. Thus the "rapidminer.r.native_lib" env. variable cannot be read from the file and set during init.

    Thus, to solve this problem just set the variable before calling the Rapidminer init.

    import com.rapidminer.tools.ParameterService;
    // The path is an example. Yours might differ.
    ParameterService.setParameterValue("rapidminer.r.native_lib", "C:\\R\\R-3.1.1\\library\\rJava\\jri\\x64\\jri.dll");
    Kind regards,

Sign In or Register to comment.