Friday, December 17, 2004

First Look at NetBeans 4.0 Final Release

Back to NetBeans. I have a project with a custom Ant script that I want to get working under NetBeans. I do the New/FreeForm Project thing, and get to the part that asks for the source folder. I specify 'com/foo/hello', and it loads both .java and .class files (at present, I leave both in the same place, which is probably bad practice, but works fine under Eclipse, and Ant doesn't mind either). Loading both seems bad, so I delete the .class files, then open a source file. It marks an 'implements' line as being an error, even though the interface I'm implementing is in the same package (and same directory). Something's wrong; I remove the project.

2nd attempt: specify the top-level path as the source folder. This time, no source files show up, and I can't find anywhere to add or import an existing file. It won't let me add the existing package, (which makes sense, as it already exists, but I was hoping it'd see it and use it, or something). I remove the project.

3rd attempt: RTFM. The docs say to specify the top part of the path, which in this case is './com'. Huh? How counterintuitive is that?! Okay, I'll play along. I figure I'll come back to the classpath thing, and just click Finish. Nothing happens. Ah, on the status bar it's giving me an error message: "java.lang.reflect.InvocationTargetException". Cancel, try again, same thing. Restart, it won't even go past the project location page. Restart, try again, now it works. Odd.

Well, sort of works, as the project list shows a 'com' folder, with 'foo.hello' and 'foo.hello.client'; I would have expected to see '' under the project name ("HelloWorld", in this case). I expand 'foo.hello', and see both my .java files and my .class files. Also not what I expected; maybe under the Files tab, but not on the Project tab. I delete the .class files.

Then I run the build, (i.e. run the 'main' target of my build.xml, which builds the whole thing). It complains about not finding the 'cc' task; it's in a jar in ~/.ant/lib. Ant from the cmdline finds it fine, but this is okay. Adding the jar to my project classpath does nothing; ah, it wants it under the additional classpath under Options/Ant Settings. Makes sense. The project compiles, and deploys. Of course, the .class files are back as part of my project. Hrm.

Sidebar: In trying to add cpptasks.jar to the Ant buildpath, NB's "Add JAR File" dialog didn't pick up my ~/.ant dir, making me type it in by hand. And not just ".ant" and hit Enter, either, as that closes the dialog; I had to navigate to "~" and type ".ant/lib/cpptasks.jar". Kind of defeats the purpose of having a dialog.

Next odd thing: Hover over a .java filename under the Project tab, and it says 'Invalid package declaration: ""'. Probably because it's separated 'com' and 'foo.hello' as two separate things. Probably wants me to have a ./src dir, and com/foo/hello under that. Let's see ... okay, that project gives me a ./src dir, with and .client packages underneath. Grr. Making me do things your way isn't very friendly.

So I need to alter build.xml to get at my source in ./src. Fixed my javac task, so now things compile okay. Fixed my javah task, but now javah gives java.lang.reflect.InvocationTargetException. Well, actually it also said it couldn't find my class; silly me, I pointed it at ./src, while it wanted ./build. So why on earth does it say "Error starting javah", when javah started fine, but just couldn't find the classfile?!

Okay, now my build.xml runs fine. Interestingly, an empty build (i.e. I just ran it, so there's nothing to do) runs in 2 seconds under NB and 6 seconds from the command line. I guess NB is using the existing JVM. Repeated clean builds take 6-10 seconds in NB, while cmdline takes 15-16 seconds. (Of course, Eclipse recompiles .java behind the scenes, which is what I usually want to build...)

Bottom line is that I got NB to work, but I'm barely whelmed. The next task will be to work in it for a few days and see if it grows on me. My boss is attracted to it, and we both would like to make an informed decision about it, or at least verify that one project can be developed by folks split between IDE's.


Post a Comment

<< Home