I am trying to call a R script from a Java program in Ecplise (Mars Release (4.5.0), jdk1.8.0_45) using
Process pid = Runtime.getRuntime().exec("C:\\Program Files\\R\\R-3.3.1\\bin\\Rscript C:\\path\\HSConcordance.R");
R script file (HSConcordance.R)
file.path = Sys.getenv("R_FILE")
setwd(file.path)
data = read.table("hscode1.csv", sep = ",", header = TRUE, na.strings = c(NA,""), colClasses = c(rep("character",4)))
dim(data)
str(data)
head(data)
write.table(data, file = "submission.csv", col.names = TRUE, row.names = FALSE, sep = ",")
It is simply importing a csv file and writing its contents to another file.
When I am trying to execute R script from the console using
C:\Program Files\R\R-3.3.1\bin>Rscript C:\path\HSConcordance.R
it is working fine creating the output file. But when I am trying to execute it from java, its not getting executed without showing any exception or error.
Do I need to install something to make it work? I have gone through rJava, Rserve, Rcaller but I don't want to use these to call a R script file from java.
Any kind of help will be greatly appreciated.