r - Rserve with java. Eval fail error 127 -


i got error , dont know , couldnt find other solution on site. run rserve in background on computer , connect local host. cant frame popup.
here code:

package rservedemo;  /**  *  * @author carl  */ import java.awt.*;  import java.awt.event.*; import org.rosuda.rengine.*; import org.rosuda.rengine.rserve.*;  public class plotdemo extends canvas {   public static void main(string[] args) {  try  {     string device = "jpeg";     rconnection c = new rconnection ((args.length>0)?args[0]:"127.0.0.1");     if             (c.parseandeval("supresswarnings(require('cairo',quietly=true))").asinteger()>0) device="cariojpeg";      else         system.out.println("(consider installing cairo package better bitmap output)");         rexp xp = c.parseandeval("try("+device+"('test.jpg,quality=90))");        if (xp.inherits("try error"))        {            system.err.println("can't open "+device+" graphics device:\n" +xp.asstring());         rexp w = c.eval("if (exists('last.warning') && length(last.warning)>0)names(last.warning) [1] else 0");        if (w.isstring()) system.err.println(w.asstring());        return;        }        c.parseandeval("data(iris); plot(iris$sepal.length, iris$petal.length); dev.off()");         xp = c.parseandeval("r=readbin('test.jpg','raw',1024*1024); unlink('test.jpg');r");         image img = toolkit.getdefaulttoolkit().createimage(xp.asbytes());        frame f = new frame("test image");        f.add(new plotdemo (img));         f.addwindowlistener(new windowadapter(){            public void windowclosing(windowevent e){system.exit(0);}         });        f.pack();        f.setvisible(true);        c.close();  } catch (rserveexception rse)         {             system.out.println(rse);         }     catch (rexpmismatchexception mme)     {         system.out.println(mme);         mme.printstacktrace();     } catch (exception e)  {     system.out.println("seomthing went wrong, it's not rserve: " +e.getmessage());     e.printstacktrace(); }      }     image img;     public plotdemo(image img)     {         this.img=img;         mediatracker mediatracker = new mediatracker(this);         mediatracker.addimage(img, 0);         try         {             mediatracker.waitforid(0);         }         catch (interruptedexception ie)         {             system.err.println(ie);             system.exit(1);         }         setsize(img.getwidth(null), img.getheight(null));           }     public void paint (graphics g)     {         g.drawimage(img, 0, 0, null);     } } 

and here error, have tried change line @ 27 couldnt useful. when run

c.parseandeval("data(iris); plot(iris$sepal.length, iris$petal.length); dev.off()");  

in r , there works. dosent seem problem.

 seomthing went wrong, it's not rserve: eval failed, request status: error code: 127 org.rosuda.rengine.rengineexception: eval failed, request status: error code: 127     @ org.rosuda.rengine.rserve.rconnection.parseandeval(rconnection.java:454)     @ org.rosuda.rengine.rengine.parseandeval(rengine.java:108)     @ rservedemo.plotdemo.main(plotdemo.java:27) 

thankful

usually process exit code 127 means file not found. in case problematic can line:

rexp xp = c.parseandeval("try("+device+"('test.jpg,quality=90))"); 

because have mistake (typo) in line:

(c.parseandeval("supresswarnings(require('cairo',quietly=true))").asinteger()>0) device="cariojpeg"; 

note: cariojpeg instead of cairojpeg


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -