7

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?

TayTay
  • 6,882
  • 4
  • 44
  • 65

2 Answers2

8

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
agstudy
  • 119,832
  • 17
  • 199
  • 261
3

Have you tried

system("path/to/file.jar")
Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168