2017-07-17 9 views
0

Javaプログラム内でRスクリプトを実行しようとしていますが、依存関係はすべてMavenにインストールされています。パッケージをロード中にRenjin IOExceptionが発生しました。関数 '.jfield'が見つかりませんでした

問題を解決するために、jfieldはrJavaによって提供される関数であることがわかりましたが、rJava(Renjinパッケージ)が実装しているかどうかはわかりません。

¿これを確認する方法はありますか? ¿何かが足りないのですか?

私のプログラムはすべて、Renjinでサポートされている、このライブラリを使用しています。

  • rJava
  • RWeka
  • RWekajarsそれらをインストールするbetadriven公共のレポトラフMavenを使用して

そして - 私。事前に

Exception in thread "main" org.renjin.eval.EvalException: IOException while loading package org.renjin.cran:RWeka: could not find function '.jfield' 

ありがとう:私はプログラムを実行するとき

package org.dfont.renjin; 

import org.renjin.script.RenjinScriptEngineFactory; 
import javax.script.ScriptEngine; 


public class TryRenjin { 
    public static void main(String[] args) throws Exception { 
     // create a script engine manager: 
     RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory(); 
     // create a Renjin engine: 
     ScriptEngine engine = factory.getScriptEngine(); 

     // ... put your Java code here ... 
     if(engine == null) { 
      throw new RuntimeException("Renjin Script Engine not found on the classpath."); 
     } 

     else{ 
      engine.eval(new java.io.FileReader("/home/dfont/renjinTest/pruebaCalculo.R")); 

     } 
    } 
} 

そして、ここに私のpom.xml、

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>org.dfont.renjin</groupId> 
    <artifactId>renjin</artifactId> 
    <version>0.1</version> 
    <dependencies> 
     <dependency> 
      <groupId>org.renjin</groupId> 
      <artifactId>renjin-script-engine</artifactId> 
      <version>RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.renjin.cran</groupId> 
      <artifactId>rJava</artifactId> 
      <version>0.9-8-renjin-5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.renjin.cran</groupId> 
      <artifactId>RWekajars</artifactId> 
      <version>3.9.1-3-b3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.renjin.cran</groupId> 
      <artifactId>RWeka</artifactId> 
      <version>0.4-34-b5</version> 
     </dependency> 


    </dependencies> 
    <repositories> 
     <repository> 
      <id>bedatadriven</id> 
      <name>bedatadriven public repo</name> 
      <url>https://nexus.bedatadriven.com/content/groups/public/</url> 
     </repository> 
    </repositories> 
    <build> 
     <plugins> 
      <plugin> 
       <!-- Build an executable JAR --> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <version>3.0.2</version> 
       <configuration> 
        <archive> 
         <manifest> 
          <mainClass>org.dfont.renjin.TryRenjin</mainClass> 
         </manifest> 
        </archive> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-shade-plugin</artifactId> 
       <version>2.4.3</version> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

最初のライン出力: はここでメインクラスをit's !

+0

コードを表示できますか? – SilverNak

+0

私のコードを置くのを忘れてしまった、初めてnoobが修正されました! – dFont

答えて

0

RenJunはまだrJavaパッケージを完全にサポートしていません。欠けているようなものの1つは、.jfieldのラッパーです。あなたはここに互換性の層を見つけることができます。

https://github.com/bedatadriven/renjin-rjava/blob/master/src/main/R/rJava.R

プルリクエストを歓迎します!

+0

だから私は誰かがラッパーをやるまでは何もしない。なぜなら私はそれをやるスキルはまだないと思うからだ。 それにもかかわらず、他のラッパー実装に関するいくつかの例がありますか?たぶん私はそれをやろうとすることができます。 返信いただきありがとうございます。 – dFont

関連する問題