问题
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