[R] Including Java files in R Package

Tobias Verbeke tobias.verbeke at telenet.be
Wed Apr 16 09:02:58 CEST 2008


Duncan Murdoch wrote:
> On 15/04/2008 7:20 PM, Hongshu Chen wrote:
>> Hi,
>>
>> I am building a package which contains some Java class files. I am planning
>> to create a subdirectory "inst/Java/" in the source directory and put Java
>> files in it, therefore after installing the package, those files will be in
>> the "Java/" subdirectory in where the package is installed. My question is,
>> how can I make references to those Java files in the R source files in my
>> package? Or is there a better way to do this?
> 
> I assume you just want to know how to find them, you already know how to 
> use them once you've found them.
> 
> The path to the Java/ subdir is given by
> 
> system.file("Java", package="yourPackage")
> 
> and so the file my.class is in
> 
> file.path(system.file("Java", package="yourPackage"), "my.class")

I made a dummy example package on how to interface
to Java code inside a package - the steps are
explained in the vignette inside the package.

http://www.openanalytics.be/doc/helloJavaWorld_0.0-3.tar.gz

It is planned to contribute this to CRAN or the rJava
website (if it is deemed useful and when it will be
a bit more mature) - feedback welcome.

HTH,
Tobias



More information about the R-help mailing list