我想从Renjin
网站http://www.renjin.org/documentation/developer-guide.html运行这个示例,我想运行第一个“简单入门”示例。
以下是我的目录布局:
这是我的代码:
package stackoverflow;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import org.renjin.sexp.*; // <-- import Renjin's object classes
/**
*
* @author yschellekens
*/
public class StackOverflow {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
// create a Renjin engine
ScriptEngine engine = factory.getEngineByName("Renjin");
// evaluate R code from String, cast SEXP to a DoubleVector and store in the 'res' variable
DoubleVector res = (DoubleVector)engine.eval("a <- 2; b <- 3; a*b");
System.out.println("The result of a*b is: " + res);
}
}
为什么我会收到以下异常?(我应该得到 6 个)
run:
Exception in thread "main" java.lang.NullPointerException
at stackoverflow.StackOverflow.main(StackOverflow.java:22)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
提前致谢