Running R from terminal via Java -


i'm trying run r using java. have r installed on mac , i've used plenty of times terminal.

in terminal, start r, 1 types "r"

ex:

 macintosh-11:desktop myname$ r  r version 2.12.2 (2011-02-25) copyright (c) 2011 r foundation statistical computing isbn 3-900051-07-0 platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)  r free software , comes absolutely no warranty. welcome redistribute under conditions. type 'license()' or 'licence()' distribution details.    natural language support running in english locale  r collaborative project many contributors. type 'contributors()' more information , 'citation()' on how cite r or r packages in publications.  type 'demo()' demos, 'help()' on-line help, or 'help.start()' html browser interface help. type 'q()' quit r.  >  

so, run r through java, via terminal. so, wrote myself java class:

public class javar {          public static void main(string[] args) throws exception {                 runtime.getruntime().exec("r");         } } 

however, when compile , execute, using

java javar 

i don't see r start. see program finish executing, , terminal ready command.

how can achieve i'm trying do?

when encountered problem, ended using jri, not creates r/java connection, allows exchange matrices , vectors to/from two.

although don't suggest it, approach may work, r not "hang" after launch it, execute nothing , exit. try adding "--vanilla" option , feed code it, --file=yourscript.r , arguments using --args

public class javar {          public static void main(string[] args) throws exception {                 runtime.getruntime().exec("r --vanilla --file=yourscript.r");         } } 

Comments