Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
org.rosuda.REngine.Rserve.RserveException:从java运行R脚本时eval失败_Java_R_Svm - Fatal编程技术网

org.rosuda.REngine.Rserve.RserveException:从java运行R脚本时eval失败

org.rosuda.REngine.Rserve.RserveException:从java运行R脚本时eval失败,java,r,svm,Java,R,Svm,我正在获取名为org.rosuda.REngine.Rserve.RserveException的rserveexpetion:eval在运行以下代码时失败 import org.rosuda.REngine.REXPMismatchException; import org.rosuda.REngine.Rserve.RConnection; import org.rosuda.REngine.Rserve.RserveException; public class Temp { publ

我正在获取名为org.rosuda.REngine.Rserve.RserveException的rserveexpetion:eval在运行以下代码时失败

import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;

public class Temp {

public static void main(String a[]) {
    RConnection connection = null;

    try {
        /* Create a connection to Rserve instance running on default port
         * 6311
         */
        connection = new RConnection();

        /* Note four slashes (\\\\) in the path */
        connection.eval("source('F:\\testFiles\\svm.R')"); //Here getting the exception
        int num1=10;
        int num2=20;
        int sum=connection.eval("myAdd("+num1+","+num2+")").asInteger();
        System.out.println("The sum is=" + sum);

    } catch (RserveException e) {

        e.printStackTrace();

    } catch (REXPMismatchException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
}
}

如何解决这个问题

这是因为在源文件中读取时没有正确初始化R函数
myAdd()
。从这里尝试回答:使用Try-catch语句查看实际的R错误。

这是因为R函数
myAdd()
没有通过读取源文件正确初始化。尝试下面的答案:使用Try-catch语句查看实际的R错误