Arduino 0017 breaks comm between Arduino/Java

There's a few guides out there that describe how to interface the arduino with a PC and Java.

http://www.arduino.cc/playground/Interfacing/Java

In both of their tutorials, they use Processing's app.Preferences to sniff the device that the PC sees the arduino as. Their code runs along the lines of:

Preferences.init();
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(
                Preferences.get("serial.port"));

This works fine and dandy up until 0017, which upgraded to Processing 1.0.3

Since the last time arduino updated its Processing library, the Preferences class has since changed init's method signature to:

static protected void init(String cmdlineargs)

http://dev.processing.org/source/index.cgi/tags/processing-1.0.3/app/src/processing/app/Preferences.java?rev=5503&view=log

And thus causing an interesting dilemma. The quick hack to get around this signature change would be to first make the class trying to implement this functionality to extend processing.app.Preferences, and to simply pass a String to init.

Unfortunately, this does not solve the problem as Preferences starts throwing more NullPointerExceptions, probably related to my subclassing of Preferences.

Has anyone successfully interfaced with Java with 0017?

Hi magitek,

I got it to work by continuing down the path you took. I extended the Preferences class with a PrefsHack class that adds a public static init() method. All it does is call Preferences.init with the String path to a preferences.txt file (I'm running on a Mac so yours may look different).

import processing.app.Preferences;

public class PrefsHack extends Preferences
{
      public static void init()
      {
            Preferences.init("/Users/Me/Library/Arduino/preferences.txt");
      }
}

Then, I had to make sure that the lib/preferences.txt, hardware/boards.txt, hardware/programmers.txt, and the *.jnilib files were in the execution directory.

After that, test application worked fine.