[R] REngine hangs when called within java code

aruni karunarathne arunikarunarathne at gmail.com
Wed Apr 15 19:47:53 CEST 2015

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);




public void fitness() throws IOException {

    String newargs1[] = {"--no-save"};

    Rengine r3 = new Rengine(newargs1, false, null);





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();


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: REngine hangs when called within java code -- problem.pdf
Type: application/pdf
Size: 48699 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150415/bfed9259/attachment.pdf>

More information about the R-help mailing list