[Rd] R and Java ? [forwarded]

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 10 May 2000 08:18:33 +0200 (CEST)


This is of broader interest,
and I'm not the expert.. 

------- start of forwarded message -------
From: Cheryl J Fernandes <cferna3@uic.edu>
To: maechler@stat.math.ethz.ch
Subject: Re R and Java
Date: Tue, 9 May 2000 13:54:35 -0500 (CDT)


Hi Martin,
    I'm Cheryl Fernandes currently pursuing my Masters Of Computer Science
at the university of Illinois, at Chicago.

I have tried and tried but just cannot manage to find teh solutuon to teh
following problem.

My question is: Can R be interfaced with Java. ??

My dilemma: I'm trying to run  the RGui program in WintNT from a Java
application. i;m using runtime.exec()
It opens teh program but after that nothing happens. After opening teh
program i'm passing some commands to R via java's process
OutputStreamWriter. But it does NOT respond to any of teh commands not
even by giving an exception. 

Coudl u please let me know if i can pass commandline commands to RGui from
within Java or are there special API's that are available. I know for a
fact taht Java does NOT have API's for R. It does have special interface
API for major programs
like C. Excel, MS-Word 

Any help would be greatly appreciated.

The code for the above is:


Runtime  rt = Runtime.getRuntime();
String strCmdTmp =""; 
strCmdTmp =  "Z:\\R\\rw1000\\bin\\Rgui ";
   
Process jproc= 	rt.exec(strCmdTmp);    	    
OutputStreamWriter o = new OutputStreamWriter(jproc.getOutputStream()); 

o.write("a<-c(4,5)\n");
o.write("mean(a)\n");
o.write("quit(\"no\")\n"); 
o.flush();
        	
String line=null;

BufferedReader reader = new BufferedReader(new
InputStreamReader(jproc.getInputStream()));
while((line = reader.readLine())!=null)
System.out.println(" The line is:  " +line);


Thanks in advance,

Cheryl Fernandes                 (Home): (312) 432 4396, (630) 834 3796 
1926 W Harrison Street,          (Office): (312) 996 4605        
Medical Center Apartments,
Apt# 1202,
Chicago, IL 60612

email: cferna3@uic.edu
       cfernand@eecs.uic.edu

------- end of forwarded message -------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._