2

I have an R package that interacts with a java dependency (jar file) via the rJava package. I have no issues making things work when developing, but I don't know how to get the package installer to keep the jars with the installation in some sort of java src directory (e.g., file.path(.libPaths()[1], "mypackage", "java"). Is this possible without needing to write custom configuration files?

I am attempting to install using devtools::install_git. My source data is organized like most other R packages (I'm using the other features of devtools as well) except that I have an additional subdirectory java where my java dependencies are stashed.

Thanks

Matt Pollock
  • 1,063
  • 10
  • 26

1 Answers1

3

Keep the jar files in /inst/java and have something like the following in zzz.R

.onLoad <- function(libname, pkgname) {
  .jpackage(name = pkgname, jars = "*")
}
jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • Thanks. This worked. Although for windows I needed to add a few lines to the `.onLoad` function as suggested by user2161065 [here](http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r) – Matt Pollock Jul 01 '14 at 12:04
  • 2
    What additions did user2161065 suggest, can you add them to the answer? – Ken Williams Sep 25 '14 at 21:13
  • @jdharrison - thank you. saved me many hours. i can't figure out why it hasn't been mentioned in any doc. – Vortex Dec 27 '16 at 06:23