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

executable, jar, java, r

Solution

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

Problem

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?

Original source