0

Calling R in java-Rcaller

After following above link I've created new "myScript.R" seperately. Please tell me that it is showing "save workspace" for saving. I've saved it as file with .R extension. Please correct me if I'm wrong.

I'm recieving the following error on running this as same Java program (provided in above link) created in Netbeans IDE for connecting RCaller with Java:

    run:
    java.io.IOException: Cannot run program "Rscript": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at javaapplicationrcaller2.JavaApplicationRCaller2.<init>(JavaApplicationRCaller2.java:41)
at javaapplicationrcaller2.JavaApplicationRCaller2.main(JavaApplicationRCaller2.java:25)
    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:288)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 5 more
    BUILD SUCCESSFUL (total time: 0 seconds)
Community
  • 1
  • 1
Aman Chawla
  • 304
  • 3
  • 8
  • 23
  • Please tell you something was successful when you are showing an error message? Sounds like a desperate sort of wishful thinking. And you are telling us nothing that would allow specific assistance. Think like a newspaper reporter: 'what' ,'where', 'how', 'when', all need to be addressed. – IRTFM Jun 22 '13 at 09:01
  • only this error is coming after running the program..it is printing nothing..I've also provided the link from where I'm taking help: http://stackoverflow.com/questions/14502187/calling-r-in-java-rcaller?rq=1 – Aman Chawla Jun 22 '13 at 09:05
  • @AmanChawla `Cannot run program "Rscript": CreateProcess error=2, The system cannot find the file specified` Java can't find `Rscript.exe`. Let me guess: You are using ..."R-2.15.1/bin/x64/Rscript" and you have install a newer version of R. 3.XXX – agstudy Jun 22 '13 at 09:59
  • using "C:\\R\\R-3.0.1\\bin\\i386\\Rscript" and version is "R i386 3.0.1" – Aman Chawla Jun 22 '13 at 10:08
  • In my own RCaller Java code I've had the path as "private final String Rexec = "C:\\Program Files\\R\\R-2.15.2\\bin\\i386\\Rscript.exe";". Try adding the ".exe"-suffix to your call. – Teemu Daniel Laajala Jun 22 '13 at 11:53
  • @TeemuDanielLaajala My last program was running correctly under Rscript, so I haven't used it before and in my case I think there is no need. I still checked what you said, same errors are coming. Anyways, how and where do you saved your myScript.R file. Sorry, but I'm new to R and I'm learning. I know how to save Workspace, but in my case I need to store it as .R extension. Please Reply!!! – Aman Chawla Jun 22 '13 at 13:11
  • 'using "C:\\R\\R-3.0.1\\bin\\i386\\Rscript" and version is "R i386 3.0.1"': I assume that you mean that this is what you have in the `caller.setRscriptExecutable` line in the code from the other link. Is that correct? I have to ask: Does C:\R\R-3.0.1\bin\i386\Rscript.exe exist? – Mars Jun 22 '13 at 13:52
  • On my system when I installed this version, the path is this only "C:\\R\\R-3.0.1\\bin\\i386\\Rscript"...Try to install this version and your path will be same if you set your directory under C: drive. I installed R from the following link for x86 i.e 32 bit OS i.e. http://cran.r-project.org/bin/windows/base/ – Aman Chawla Jun 22 '13 at 15:23
  • Can anyone tell me that I want to upload the application created by me in jsp, I want to avoid this thing of writing the path i.e this R path on system. Can I bind it in any way, as the path is to be changed and R is to be installed every time the work is shifted from one system to another. – Aman Chawla Jul 23 '13 at 12:52

0 Answers0