Running R script from java - Rconnection eval exce

2020-07-27 06:38发布

问题:

How can I solve this problem? I tried to empty cache, reinstall R and Rscript.

connection = new RConnection();

String path = "source('" + rScript.getFile().getAbsolutePath() + "')";

connection.eval(path);

// error in this line org.rosuda.REngine.Rserve.RserveException: eval failed

In a source file, I have this code

functionName <- function(param1, param2, ...,  paramN){
  #some code here
}

If I remove functionName <- function(param1, param2, ..., paramN){ definition part - it works.

Also in R console log appeared this error message:

Error: long vectors not supported yet: qap_encode.c:36 Fatal error: unable to initialize the JIT

回答1:

Do you still have this issue?

I exactly had the same issue, which is

Error: long vectors not supported yet: qap_encode.c:36 Fatal error: unable to initialize the JIT

I am currently using macbook (HighSierra) and R version of 3.5.0 and java 1.8.0.151.

How I solve this issue is to know what version Rserve is installed on your computer. To check the version of Rserve, go to Rstudio and type:

packageVersion("Rserve")

and return value will show you the version of "Rserve".

If return value is 1.7.3, then I think this is the where error starts.

If the version of Rserve is 1.7.3, then please try to upgrade your version of Rserve.

install.packages("Rserve", "Rserve_1.8-6.tgz", "http://www.rforge.net/")

This instruction is also addressed on "Rforge" website: http://www.rforge.net/Rserve/files/. When you click this link and scroll down to "Repository contents", it is written in small font-size saying "please use blah blah blah". This is where the "install.packages("Rserve,....)" comes from.

I know that only few (at least on online-world) has or had faced this problem and I spent 2 days on solving this.

Hope this helps you.

ps. packageVersion() can be different based on the OS you use.



标签: java r rserve