Today I'll comment my favourite IDE for Java development - NetBeans.
Some may say that I'm a newbie and like less complicated IDE or that "true Java developers" use Eclipse - OK so be it, but I'm working on Eclipse at work and at home I'm using whatever I feel like using and NetBeans is what I like using!
So I've recently found a few bugs while developing a small application.
1. Swing forms editor bug
NetBeans is popular with its very well-made Swing UI editor and I agree with common understandings. UI forms are easy to use, can be configured in lots of ways (some of which I haven't tried yet), but satisfies my needs completely. It generates some code and locks it , so that future UI replacement/movements are still consistent with the rest of the class you are managing. Easy event handling methods and so on...
But I've had a few places I wanted to manipulate and configure the initialization of the components. NetBeans automatically creates a constructor with "init();" method call in it , but my case required to modify this init() method.
So you can click on the JComponent and click "Customize code" , which lets you modify the constructor called but not the declaration! I found this very restrictive and tried to trick NetBeans.
I had to change the place of a class from package "a" to package "b", but if I cannot change the declaration, I'm stuck. So I decided to use REFACTOR rename on the package of the problematic class. And it worked! ...
at first...
I refactored the name of the package and no problem in the UI created code.
But if you try to move 1 pixel of the UI form , it regenerates again the locked code and refreshes the metainf. xml in the netbeans project and my IDE shows an error of non-existing class/package...
I'm going to report this and get it fixed in NetBeans 6.9.
2. Main class in built .jar is missing
The next major bug I've found is already reported. I even reached the helpful guys in www.stackoverflow.com
You can find my question here -> Main class in NetBeans bug
I'll rewrite the short description here:
You create a Java project in NetBeans 6.8 or 6.9 and build it to create a .jar file.
Even if you have set in the project settings which class contains the main() method to be executed, the build omits this configuration in the meta-inf/manifest file after build and so the .jar is not executable.
This is easily fixed by :
- creating a metainf.mf file in root of your project
- the file contains something like
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01 (Sun Microsystems Inc.)
Main-Class: com.example.MainClass
Class-Path: lib/lib1.jar lib/lib2.jar
- editing the nbproject/project.properties file
- add manifest.file=manifest.mf
- save and rebuild
This solved my problem and thanks a lot to the NetBeans and stackoverflow society so quickly.
L.K.
No comments:
Post a Comment