Hi,

I'm wondering if anyone can help me. I'm writing java application that using
JRclient and Rserve to communicate with R. I want to get response from R for
command:

x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),matrix(rnorm(100, mean =
1, sd = 0.3), ncol = 2))
kmeans(x, 2, 22, algorithm = "Hartigan-Wong")

and put result of kmeans() function in my TextArea.I've tried something like
that:

zz <- file("ex.txt", "w")
capture.output(kmeans(x, 2, 22, algorithm = "Hartigan-Wong"), file = zz,
append = TRUE)

and then get "ex.txt" file from R and rewrite it to my local file using java
method:

public void saveFileFromServer(Rconnection rConnection, String fileName,
            String pathToSave) throws Exception {

        RFileInputStream ris = rConnection.openFile(fileName);

        FileOutputStream outs = new FileOutputStream(pathToSave + "/"
                + new File(fileName).getName());

        byte[] buf = new byte[1024];
        int n = 0;
        while ((n = ris.read(buf)) != -1) {

            outs.write(buf, 0, n);
        }

        outs.flush();
        ris.close();
        outs.close();
    }

It works fine (i have file "ex.txt" with results) when i run my application
from Eclipse.
Problems starts when i put application in jar. In that case my "ex.txt" file
is empty.

Can anyone tell what i'm doing wrong?

Thanks in advance

Tomek Spulak

	[[alternative HTML version deleted]]


