JRI

In Mac:

.Install R
.install.packages(“rJava”)

Create Java Application with eclipse:

import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;


public class JavaToR {

	public static void main(String[] args) {
		System.out.println("Hello");
		
		// Start R session.
		Rengine re = new Rengine (new String [] {"--vanilla"}, false, null);

		// Check if the session is working.
		if (!re.waitForR()) {
		    return;
		}

		re.assign("x", new double[] {1.5, 2.5, 3.5});
		REXP result = re.eval("(sum(x))");
		System.out.println(result.asDouble());
		re.end();
	}

}

Run application config:

VM arguments: -Djava.library.path=/Library/Frameworks/R.framework/Resources/library/rJava/jri/
Environment variable: R_HOME: /Library/Frameworks/R.framework/Resources

More linkes:
1. https://stackoverflow.com/questions/4894002/question-about-jri-error
2. https://bioincloud.wordpress.com/2015/04/02/jri-javar-problem-java-lang-unsatisfiedlinkerror-no-jri-in-java-library-path/
3. https://autofei.wordpress.com/2010/08/04/getting-rjavajri-to-work-it-is-painful/
4. http://www.studytrails.com/r/r-and-java-jri-using-eclipse/

Read More