Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the classpath for rJava in R?

Tags:

r

classpath

I have a package for R which contains several jar files. For better maintenance I want to split the jars in a separate package and have the R source and two small jars in the main package.
But now I always get a "NoClassDefFoundError" from rJava, if I call my functions.

In the main package I have an onLoad function, which starts the JVM with the .jpackage function.
According to the help this function takes a "morePaths" argument, to which I provided the absolute path to the two jar files. But it won't work.

I also tried using

jar.one = paste(lib,pkg,"java","One.jar",sep=.Platform$file.sep)
jar.two = paste(lib,pkg,"java","Two.jar",sep=.Platform$file.sep)
.jinit(classpath=c(jar.one,jar.two))

Inside the onLoad function.

Any hint would be appreciated,
Martin

like image 739
Martin Avatar asked Jun 23 '10 17:06

Martin


1 Answers

Try .jaddClassPath

.jaddClassPath("blah.jar")
like image 196
Shane Avatar answered Oct 26 '22 21:10

Shane