R rJava (.jinit()) stops working - make it work again

Windows 8, 64 bit, 64 bit Java 7, 64 bit R…

Apparently (!) it worked before. And then R said it was “Unable to create a class loader” (no arguments) or that it couldn’t start the JVM (with arguments) when using .jinit.

Unfortunately, I can’t say exactly what was wrong, or why it apparently stopped working, but these two things fixed it:

Add jwm.dll to the path

Set the JAVA_HOME environment variable to the location of Java (one folder above bin)

And I used the more recent JDK folders (including the server folder within the JRE that came with the JDK) and not the JRE-only that was also installed but appeared to be an earlier version.