Dear All, I'm creating a project which uses both java and R.
I created the java class named MyClass and within that wrote two separate methods (graphing1() and fitness()) to call the r scripts. public void graphing1() throws IOException { String newargs1[] = {"--no-save"}; Rengine r1 = new Rengine(newargs1, false, null); r1.eval("source('test2.R')"); r1.end(); } public void fitness() throws IOException { String newargs1[] = {"--no-save"}; Rengine r3 = new Rengine(newargs1, false, null); r3.eval("source('A.R')"); r3.eval("source('B.R')"); r3.end(); } Both of the above methods are in java class MyClass. >From another class in the same project for which I created a gui, I accessed the fitness() function and it worked fine. But when I try to call the graphing1() function it did not work. (both were called through the gui) The programme hangs at ; Rengine r1 = new Rengine(newargs1, false, null); without any notification. In both instances I called the function as follows: 1st instance: MyClass test=new MyClass(); test.fitness() ; 2nd instance: MyClass test1 = new MyClass(); test1.graphing1(); All the 3 scripts are coded to create png files. test2.R and A.R scripts use the ROCR library and B.R do not use any. All the 3 files end with dev.off() statement. I have installed R 3.1.3. I’m using netbeans as the editor and working in windows environment. The 3 scripts work fine when executed in R environment. The issue arises when it’s called from the java code. I'm a student who is new to R and was struggling to solve this issue for several weeks. Your help is greatly appreciated. Thanks in advance.
REngine hangs when called within java code -- problem.pdf
Description: Adobe PDF document
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.