How can I run an executable .jar file in an R script?

此生再无相见时 提交于 2019-12-23 09:00:25

问题


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?


回答1:


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

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:


Have you tried

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


来源:https://stackoverflow.com/questions/20291904/how-can-i-run-an-executable-jar-file-in-an-r-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!