This project is read-only.

Error in .jinit(): Cannot create Java virtual machine (-4)

Mar 3, 2014 at 4:26 PM
Hello All:
i am trying to use the rJava package that runs a .jinit() to create a Java Virtual Machine. It works fine from within R, however, when using the RDotNet, it gives the above error.
I have added the JAVA_HOME, and bin directory to the path, but to no avail. Any pointers would be much appreciated.

Here's a quick snap of the code.

Mar 3, 2014 at 11:09 PM
This worked just fine for me with no particular setup compared to other code run via R.NET. I used the latest R.NET development code but don't see any reason why this would not work with R.NET 1.5.5.
      private static void ReproDiscussion537259(REngine e)
         e.Evaluate("f <- .jnew('java/awt/Frame','Hello')");
The error message is in the native code of rJava (rJava\src\init.c) when a call to JNI_CreateJavaVM fails. I dug around to find the meaning error code (-4). I am nonplussed, to say the least, by searching through

Your JVM seems to complain about a lack of contiguous memory to initialise. This is very likely to be machine specific, so you'll have to use your Java know-how to figure out what to do. The first useful hint I came accross was in an old post. A problem described on StackOverflow seems also to share some technical characteristics with your issue.

Hope this helps. Please post a reply if you find a work around your issue.
Mar 5, 2014 at 4:19 PM
Thanks for the quick response. I am equally surprised as to see why it would not work. I haven't tried it on other machine yet, but will give that a shot very soon. I also tried it with java options to increase the heap size such as -Xmx1g, -Xmx512m etc, but to know avail. I'll keep this post updated as I come across something. Thanks!