[Rd] rJava is not working in Solaris through java

Praveen Kumar prawin.pop at gmail.com
Fri Dec 21 11:46:50 CET 2012


Hi,

we have installed R in solaris 10 sparc machine. After installing R we have
installed rJava package and we did a sample test using R prompt it worked
well. We have written sample Java class to calculate GLM and LM functions.
When we execute the sample java class it returns null for both the
functions. But both the functions are working fine in R console.

sample java class code.



import org.rosuda.JRI.REXP;
import org.rosuda.JRI.RVector;
import org.rosuda.JRI.Rengine;


public class rtest {
        static Rengine re;
 
        public static void main(String []a)
        {
                try
                {
                        re = new Rengine(a, false, null);
                        REXP x11 = re.eval("a<-sample(1:1000,300)");
                        REXP x12 =  re.eval("b<-sample(1:1000,300)");
                        REXP x13 =  re.eval("d<-sample(1:1000,300)");
                        REXP x14 =  re.eval("f<-runif(1:300)");
                        re.eval("value<-glm(f~a+b+d,family=binomial)");
                        REXP x1 = re.eval("value");
                        REXP x2 = re.eval("coef(value)");
                        System.out.println(x1);
                        System.out.println(x2);
                        REXP x111 = re.eval("aa<-c(5,1,3,4,2)");
                        REXP x112 =  re.eval("bb<-c(7,8,6,9,4)");
                        REXP x113 =  re.eval("dd<-c(1,0,1,0,1)");
                        REXP x114 =  re.eval("lm(dd~aa+bb)");
                        System.out.println(x111);
                        System.out.println(x112);
                        System.out.println(x113);
                        System.out.println(x114);
        }
                catch(Exception e)
                {
                        e.printStackTrace();
                        re.end();
                        //s.end();
                }
                finally
                {
                        re.end();
                        //s.end();
                       
                }
        }

}


Thanks in advance.

by,
Praveen Kumar 



--
View this message in context: http://r.789695.n4.nabble.com/rJava-is-not-working-in-Solaris-through-java-tp4653701.html
Sent from the R devel mailing list archive at Nabble.com.



More information about the R-devel mailing list