Using Netbeans with an existing project

§    Startup

First download, install, and make sure "netbeans" is in your PATH. I downloaded the full version, then selected "Base IDE", "Java SE", "Web & Java EE", "UML", "Ruby", and "C/C++".

Start "netbeans" with no arguments.

The first time it may hang a while "Checking for updates..." particularly if you have a Proxy, but eventually it becomes responsive. You will be able to begin work even if it says it is updating a database.

§    Slow refreshing

Netbeans has a way of refreshing stuff asynchronously, so you do not always see an expected result right away.

On the other hand, you can usually do something else at the same time.

It can take a while to populate an entire projects tree, and it only begins when you open the branches.

The first few times it started up very slowly, looking for updates that it could not find. I finally told it where to find an HTTP proxy. The next time it started with a blank frame for about 30 seconds. A couple minutes later it said it had found 26 updates. These took a while to download and install. In the meantime the response was very sluggish.

§    Setup with a typical existing ant project

To use with an existing project, go to File -> New Project. and select Java -> Java Free-Form Project.

I set the Location to my top-level "foo" project directory. It detects a build.xml that exists in that directory for the "Build Script."

For "Build and Run Actions" I choose the target that builds my project jar as the Build Project. The other targets are pretty obvious.

For source package folders, I select src

The GUI may seem not to be reacting responding after you select and add items on some of these menus, but the list does eventually refresh. Be patient.

For "Java Sources Classpath" I select all jars in my jar/ subdirectory.

For "Project Output" I select build/cls for "Output JARs or Folders Containing Compiled Classes."

"Javadoc Output" goes to build/javadoc

Hit the "Finish." I missed a couple things the first time, but I could change them them. Select the Projects tab, right-click on the project "foo", and select Properties.

If you use CVS or SVN, they should be detected automatically. You may be asked for your password.

§    Running files

The first time you try to run a class as an application, Netbeans will create an Ant build file in the nbproject subdirectory. I edit nbproject/ide-file-targets.xml and add to enable assertions. I think this is a much nicer approach to configuring runtime behavior.

If your build.xml uses a different ant version than the one provided with Netbeans, then you can change it at Tools -> Options -> Miscellaneous -> Ant tab.

§    Style warnings

I like to turn on as many warnings as possible.

Go to Tools -> Options -> Java Code -> Hints.

I check all boxes except for "braces" and "Netbeans development."

I then expand all these checked boxes and check all boxes within them. Change any "Warning on Current Line" to a "Warning"; otherwise, you will not see that warning until your cursor is on that line.

I check "Create Javadoc" for protected methods, and check "Error in Javadoc" for private methods.


Return to parent directory.