Interesting.

It might be worth-while posting a sample so someone could figure out why it worked in NetBeans and not outside.

Bug checking is difficult, you could try FindBugs - it helps you locate many of those hard-to-spot bugs. There is a NetBeans plugin, but I prefer running it from the command-line though.

Get more information from http://findbugs.sourceforge.net/