yannrichet/rsession

[exception] R environment not initialized.

Closed this issue · 4 comments

Hello, I am a novice. My PC is window10, Please help me that how I can run successfully, thank you very much:

public class RC {
public static void main(String args[]) throws RException {
Rsession rc = RserveSession.newInstanceTry(System.out,null);
rc.eval("print(1)");
rc.end();
}}

(!) No Rserve conf given. Trying to use R://localhost:6311
failed: timed out
Connection R://localhost:6311 failed.
(!!) Rserve R://localhost:6311 is not accessible.
Trying to spawn R://localhost:6311
(!!) Failed to find R_HOME (with default null) as null
(!!) Failed to find R_HOME (with default null) as null
Failed to find R_HOME (with default null) as null
(!!) Failed to find R_HOME (with default null) as null
(!!) [exception] R environment not initialized.
Exception in thread "main" java.lang.IllegalArgumentException: [asString] Not an REXP object: org.math.R.Rsession$RException: [exception] R environment not initialized.
R: [exception] R environment not initialized.

It seems you don't have R language already installed on your machine.
So if you just wish to call some simple command like print(1), you can use R2jsSession instead of RserveSession.
Otherwise you can also use RenjinSession, but then you need to have Renjin jar in your classpath.

Thank you very much for your reply. My R version is 4.0.1, is it because my installation path is wrong?

Wow, I succeeded. I changed the version of R to 3.5.3, and then installed it in C:/Program files/R, then it run! thank you very much!

Ok, I think I understood what happened.
It should be because RserveSession searchs the R install subdirectory starting with "3.".
So if you really want t use R 4.*, you can just setup the R_HOME path using an environment variable (eg. in command line before launching java).