[R] rJava: System.exit(1) in Java causes R crash

Simon Urbanek simon.urbanek at r-project.org
Wed Aug 18 17:26:01 CEST 2010


On Aug 18, 2010, at 12:18 AM, Sigal Blay wrote:

> I'm writing a package that successfully calls Java from R using rJava.
> When R sends my Java function bad data (through .jcall()), 
> I get the error message details (when I run it on a console)
> and then:
> 
> Java requested System.exit(1), closing R.
> 
> Is there a way to call .jcall so that when Java receives bad data,
> the Java function will exit, but won't take down R with it?
> 

That is really up to your Java code. Your code called System.exit() which terminates the application. If you don't want that, just don't call exit(). "exit" is not used to "exit a function" but to exit the entire application. You want a function to "return" not to "exit" so change your code accordingly.

Cheers,
Simon



More information about the R-help mailing list