Ant Compile With rJava library

This is pretty simple but for the sake of “I-will-not-forget-it-anymore” I will write it here. I copied some files of a Java project to a new machine. When I tried to execute it in the new place, “Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version number in .classa file”. Recompiling everything should make it work. Since my code requires rJava it is necessary to inform this to the ant (I’m using ant by the way).  The command which made my day is:

ant clean compile -lib ~/R/i486-pc-linux-gnu-library/2.9/rJava/jri/JRI.jar

2.9: be aware about the version you’ve installed, if you’ve compiled the packages in a version < 2.10, you will need to reinstall ’em. In my case I did reinstall nlme, mgcv, spatstat, and igraph.

cannot mkdir R_TempDir (não é possível criar um diretório em R_TempDir)

I’m constantly using rJava/JRI for a large amount of simulations. Repently it was not working anymore, and since I’d not change anything in the main code, it was a quite weird behavior. My rJava binding looks like this and the first line was the only being executed:

System.out.println("Creating Rengine (with arguments)");
re = new Rengine(args.split(" "), false, null);
if (!re.waitForR()) {
System.out.println("Cannot load R");
System.out.println("R loaded");

That was awkward so I tried to use R in the console. When I execute the “R” command I received “cannot mkdir R_TempDir”. So I dug into the R source code to know when it happens. So I figured out that R tries to read environment variables TMPDIR, TMP, and TEMP before set “/tmp” as default one. Since this variables were not set, the “/tmp” is the destiny of the temporary stuff.

When I saw my “/tmp” directory was full, I mean, filled with the maximum number of directories possible in an Ext3 File System, 32K. I realized that all the problem was that R was not getting space for the new “Rtmp…” directories.

To solve that, “rmdir Rtmp*” inside “/tmp” dir. And the world is a happy place again.