Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatic R wrapper generation for java methods

Tags:

java

r

I am trying to use a Java package from R.

RJava provides a way to call Java from R, but wrapping all the methods is impractical.

Does anyone know of a script that generates wrappers for a package (say, by processing the relevant javadoc)?

like image 765
gappy Avatar asked Nov 17 '25 07:11

gappy


1 Answers

I could be wrong, but having used rJava fairly extensively, I'm quite sure that nothing like that exists.

While implementing my own packages with rJava, I went through the source code for many of the packages that reverse depend on it (you can see these at the bottom of the CRAN page). None of these had anything that looked like automated code.

Incidentally, for anyone unfamiliar with it, I strongly recommend reading the vignette and looking at the source code for the helloJavaWorld package; it was specifically created to help with this process.

What you're suggesting would be a very welcome improvement. I'm happy to collaborate on creating it if anyone has interest.

Edit

Romain Francois just pointed out that this feature now exists in rJava (actually, as of October 2009). Here is an example:

> require( rJava ) ; .jinit() 
> attach( javaImport( "java.lang" ) ) 
> Math$PI 
[1] 3.141593 
> Math$abs( -3 ) 
[1] 3

Once you import a class, you also get auto-completion by, for instance, Math$[tab].

like image 148
Shane Avatar answered Nov 18 '25 21:11

Shane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!