I got following simple R-program named hello.R:
print('hello')
I like to call this code from Java now. This is my code in Java:
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String path = "C:\\Users\\Administrator\\Desktop\\hello.R";
try {
Runtime.getRuntime().exec("C:\\Program Files\\R\\R-3.1.3\\bin\\Rscript "+path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I was expecting it to print the hello statement in the Java concole. But Java program didn't do anything at all.
Do you know what the problem may be?
path) with another absolute path inRuntime.exec()- even without a path separator!pathas argument.