tags:

views:

28

answers:

1

Hi,

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

A: 

Try .jaddClassPath

.jaddClassPath("blah.jar")
Shane
Just tried this one. Doesn't work.
Martin
This is the right way (the only way?) to add Jars to a classpath in RJava. You're trying to have your jars in one package, and then call them from another? Not sure if that will work. Why would you even want to do that? If you need to separate packages, put wrapper R functions in the "jar package" that you will then call from your second package.
Shane
If I try .jaddClassPath("blah.jar") the jar file(s) don't show up in the output of .jclassPath().And I have to split the package, because the libs are to big. For better version control.
Martin
Just discovered that I have rJava 0.8-4 installed, which contains a bug regarding the .jclassPath output. Installed 0.8-5 and now it shows the modified classPath.
Martin
So .jaddClassPath worked for you? If so, please accept the answer to signal to future visitors. Otherwise feel free to post your final solution.
Shane