Hi all,

first of all: Sorry for my bad englis, and now the Question:

I have some problems with running R from Java. First i tried using rJava (JRI). 
But the examples didnt work properly.

Now im trying to establish a connection by using Rserve and JRclient (RF503). 
I have the following code, which i`ve found:

------------------------------------------------------------------------

public class RTester {


        
        public static void main(String[] args) {
        Rconnection c = getLocalRconnection();
        if (c != null) {
            try {
                double[] d = c.eval("rnorm(10)").asDoubleArray();
                for (double n : d)
                    System.out.println(n);
            } catch (RSrvException e) {
                e.printStackTrace();
            }
        }
    }

    private static Rconnection getLocalRconnection() {
        try {
            return new Rconnection();
        } catch (RSrvException e) {
            //If we get this kind of error, it may be because Rserve is not 
running
            if (e.getMessage().equals("Cannot connect: Connection refused")) {
                try {
                    String rserveStartCommand = "R CMD Rserve --vanilla";
                    //do a blocking call to the shell command for starting 
Rserve
                    int exitValue = 
Runtime.getRuntime().exec(rserveStartCommand).waitFor();
                    //if it returned success, try connecting again
                    if (exitValue == 0)
                        return new Rconnection();
                    //otherwise, Rserve is probably not installed
                    else
                        System.err.println("Could not start Rserve - is it 
installed properly? Shell command \""+rserveStartCommand+"\" exited with exit 
value "+exitValue+".");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            else
                e.printStackTrace();
        }
        return null;
    }


-------------------------------------------------------------------------
The Problem ist, that i get the following Exception:
org.rosuda.JRclient.RSrvException: Handshake failed: The server uses more 
recent protocol than this client.
        at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:113)
        at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:58)
        at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:42)
        at tester.RTester.getLocalRconnection(RTester.java:28)
        at tester.RTester.main(RTester.java:14)


Well, i understand, that tehre seems to be a version problem, but i dont 
understand what kind of. Im using the most recent Versions of RServe and 
JRclient which i could find on the page.

btw. im using Windows XP Pro and Eclipse ganimed (recent Version) as IDE.
Java jdk is at version 1.6.

Thx in advance for any help!
-- 
GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und Telefonanschluss
für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to