2

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)

前もって感謝します

4

1 に答える 1