[英]Include jar file when creating an R package
我創建了一個骨架R包:
lib
jarFileHere.jar
R
r_code_file.R
該r_code_file.R試圖引用在jarFileHere.jar類文件:
library("rJava")
library("rjson")
.onLoad <- function(libname, pkgname) {
.jpackage(pkgname, lib.loc=libname)
}
.onLoad("packagename", "../lib/jarFileHere.jar")
.jnew("com/test/ClassHere", "")
但是由於java.lang.NoClassDefFoundError我失敗了。
我能夠使用它
.jinit
.jaddClassPath("../lib/jarFileHere.jar")
但是rJava文檔明確表示不使用.jinit,因為當代碼用作包時它不起作用。
使你的結構像:
inst
java
jarFileHere.jar
R
r_code_file.R
有關如何在包中包含java的示例,請查看helloJavaWorld包。
另請參閱Deducer和DeducerplugInExample的來源。 在Deducer的網絡手冊中有一個關於在你的軟件包中包含java代碼的教程: http : //www.deducer.org/pmwiki/pmwiki.php?n = Main.Development#suaptijc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.