java - R connection issues with relative path and executable jar -


i writing java application in intellij ide. application uses rserve() connect r , access scripts. first question is: @ moment, r scripts directly under main java project folder. access r script, create rconnection , use following code:

rconnection rc1 = new rconnection(); rc1.assign("parsefile", currentpath.concat("/parsefile.r")); rc1.eval("source(parsefile)"); 

the currentpath variable in code absolute path, obtain using this:

 final string currentpath = currentrelativepath.toabsolutepath().tostring(); 

however, want make changes in code , access r scripts using relative path. this, created folder named rscripts in src folder , placed r scripts in folder. marked directory sources root using mark directory as option in intellij. access scripts made following changes code:

rc1.assign("parsefile", "/rscripts/parsefile.r"); rc1.eval("source(parsefile)"); 

however, error:

org.rosuda.rengine.rserve.rserveexception: eval failed, request status: error code: 127 

looking @ error, seems r script cannot accessed. how should use relative paths access r scripts?

secondly, want deliver application jar file. should bundle r jar file, in case user not have r installed on system?

my guess should change r working directory correct location using setwd(). after can suffice passing file name source() function.


Comments