[Rd] problem using rJava with parallel::mclapply

Jeroen Ooms jeroenooms at gmail.com
Fri Jun 20 04:32:51 CEST 2014

On Mon, Nov 11, 2013 at 6:20 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote:
> It’s a limitation of the Java runtime - you cannot fork a JVM. This is true for most libraries that use long-lived threads or any kind if UI (see the warnings in mcfork).

Is there some way to reset or restart the JVM within the fork? For
example, the following code seems to work in the terminal on mac/linux
(not in macgui):

myfile <-  system.file("tests", "test_import.xlsx", package = "xlsx")
mccollect(mcparallel({xlsx::read.xlsx(myfile, 1)}))

But if we load the 'xlsxjars' package in the parent process, the
example does not work anymore as Simon explained:

mccollect(mcparallel({xlsx::read.xlsx(myfile, 1)}))

Would there be a way to work around this by manually forcing a reset
of the JVM in the child process, in order to get the similar behavior
as if the 'xlsxjars' package was not loaded in the parent process? I
tried unloading 'xlsxjars' with ?detach, but that seems to make things

More information about the R-devel mailing list