Showing posts with label ide. Show all posts
Showing posts with label ide. Show all posts

Wednesday, May 19, 2010

NetBeans 6.8 bugs

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.

Wednesday, May 12, 2010

Debugging Eclipse

Today I had the chance to debug some functionality in the Eclipse IDE, or to be more precise the SAP NetWeaver Developer Studio customized version of Eclipse.

The main thing about debugging is to setup your environment the right way.
There is configuration.ini file in the main directory of your IDE. Inserting specific parameters allows the NetWeaver DS to be started in debug mode and on specified port.
Then you need to start a debug session as a "Remote application" on 'localhost:port' and you are good to go.

 I managed to do that but I lost some time figuring this thing out :
- better make a copy of your IDE and not debug your IDE with the same one.

What I mean is that you can open 2 times the same IDE and debug one of them with the other but here's the tricky part. If you want to make update to a file in the IDE you want to debug, you will have to shut down both instances and start them up again. And lets suppose you have to change not 1 file but a few files, and not just 1 time, but a few times... and then you have wasted your time.


Personal advice - make a separate copy of your IDE and use it for DEBUG and leave your main IDE untouched.

 

Other than that, there is nothing special about it.

L.K.