I am working with a Java and I need to use an add-on R library and use the functions within that library. I tried the answers provided in the following questions
How I can load a R script into JRI and execute from Java?
Problem loading R own created libraries in Java/JRI code
but I still get a NullPointerException. Can anyone point out the error. Thankyou
Here is the code which I am using:
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.RVector;
import org.rosuda.JRI.Rengine;
public class RConnect {
public void processFiles(String[] spectrumData)
{
// new R-engine
Rengine re=new Rengine (new String [] {"--vanilla"}, false, null);
if (!re.waitForR())
{
System.out.println ("Unable to load R");
return;
}
else
System.out.println ("Connected to R");
REXP rexpSetFolder = re.eval("setwd('/home/user/R/x86_64-pc-linux-gnu-library/3.0')");
REXP rexpFolder = re.eval("getwd()");
System.out.println(rexpFolder.asString());
REXP rexpLoad = re.eval("library(PROcess)");
RVector f1 = (re.eval("read.files(spectrumData)").asVector());
System.out.println(f1);
re.end();
}
}