如何在R脚本中运行可执行的.jar文件?

时间:2022-08-10 01:10:51

I am working on a relatively large data analytics project in which an R script I wrote is the primary executable, calling all other bits of code. I can't figure out how to call an executable .jar from my R script, however and I haven't seen this question posted elsewhere... is this a possibility?

我正在开发一个相对较大的数据分析项目,其中我编写的R脚本是主要的可执行文件,调用所有其他代码。我无法弄清楚如何从我的R脚本中调用可执行文件.jar,但是我没有在其他地方看到这个问题...这有可能吗?

2 个解决方案

#1


7  

You can use rJava to create an instance of your java Object. Then you call its methods ..

您可以使用rJava创建java Object的实例。然后你调用它的方法..

library(rJava)
.jinit(PATH_TO_YOUR_JAR) # this starts the JVM
jobject <- .jnew("yourJavaClass")  ## call the constructor
.jcall(jobject ,"I",method="YOUR_METHOD") ## call a method

#2


3  

Have you tried

你有没有尝试过

system("path/to/file.jar")

#1


7  

You can use rJava to create an instance of your java Object. Then you call its methods ..

您可以使用rJava创建java Object的实例。然后你调用它的方法..

library(rJava)
.jinit(PATH_TO_YOUR_JAR) # this starts the JVM
jobject <- .jnew("yourJavaClass")  ## call the constructor
.jcall(jobject ,"I",method="YOUR_METHOD") ## call a method

#2


3  

Have you tried

你有没有尝试过

system("path/to/file.jar")