Monday, September 3, 2007

Netbeans & Polish

This is the kind of thing that can take forever, and annoys me to no end: In Netbeans I set up a dependency from my project to another project. The editor recognizes the dependency, and correctly looks up the appropriate .jar file and lets me syntax check my files from the editor.
Nice. I then try to compile, and the paths are all F**** UP. They seem correct enough (and as I said, the NetBeans editor is capable of using them), but none of my libraries are actually located by the compiler.

On days like this the thought of spending the rest of my days as a monk somewhere in the Himalayas seems quite attractive.

Now, when solving this problem a natural place to start is to read the fine manual :-) On page
45 in the complete guide to j2mepolish it says:

J2ME Polish normally calls the Java
compiler normally with the appropriate
classpath as well as bootclasspath for
the current target device.


Well, don't believe it. It's just not true. You can add libraries and projects to the buildpath generated by NetBeans, it simply won't be used. What you have to do is to look at page 182, where the real story is told on "How to Integrate a Binary Third Party API":



When a third party API is only available in binary form, they can
be integrated with the “binaryLibraries” attribute of the element
in the “build.xml” file. This attribute can point to jar or zipfiles
or to a directory containing third party libraries (either jarfiles,
zipfiles or classfiles). Several libraries can be separated by
colons ':' or semicolons ';'. When the libraries are situated
in the “import” folder, only the name of the libraries need to
be given (instead of specifying the full path).

Turns out what you have to do is to stick the files in an "import" directory in the project's top level directory and then put a reference to that into the "build" construct in the antfile . I won't tell you how many hours it took to figure this one out, it's just too depressing.