Setting up small freeform project correctly - what are all these settings for?

What is freeform?

Freeform is a NetBeans project type that allows you to use Ant build script supplied with your sources. Typical usecase can be that you have already some sources, you are developing them "in you own way" (other IDE, or using VI, or...) and you want to work on them using NetBeans. Other common usecase for free-form can be that you check out some opensource project and you want to work on it in NetBeans IDE.
Let's take a look at some example. For a simple project, let's assume you have structure like this:
  • my_project
    • src
    • - contains Java sources
    • build
    • - this is where you build script puts \*.class files
    • lib
    • - some JAR libraries you depend on
    • javadoc
    • - here is generated output from javadoc target in build.xml
    • tests
    • - tests for your sources
    • other
    • - misc stuff
    • >build.xml
    • - you own build script
Of course this is just en example structure, and let's say ideal ;-). So if you want to set up this project as NetBeans project, you have to do something like this:
  1. Invoke New project wizard (File | New project | Java > Java Free-form project)
  2. Name and location panel
    • Location
    • - here you specify general location of your project. In this example you would browse for my_project folder
    • Build script
    • - if it's found under the project's folder, field gets populated automatically. Otherwise browse for your build.xml
    • Project name
    • - gets auto-populated from build.xml, feel free to change it if you wish
    • Project folder
    • - this is where your NetBeans project metadata will be stored. You will later open it in IDE using this project folder. It is possible to place it to other location than location of your project folder (my_project)
  3. Build and Run Actions panel
    • Here you just bind Ant targets to IDE actions. IDE tries to guess some of them. Modify as you wish.
  4. Source Packages Folders panel
    • Add here src folder as Source packages and tests as Test packages.
    • Hit Includes/Excludes button, it brings up dialog where you can setup what do you want to have in you source root visible. If you have e.g. HTML files mixed together with Java files in package folders, you may wish to exclude those HTML files, so that IDE's projects view won't display them.
  5. Java Sources panel
    • You need to set up project dependencies here. If you on know which JAR libraries your project depends, you can add them right now. Usually they are placed in lib folder, or similar, and are distributed together with project. Ideal case. If you have no idea, leave this empty, you can set up this later using Project properties dialog.
    • In the same way you set up dependencies for sources, set up also for tests.
  6. Project output panel
    • Here comes the tricky part. You need to bind here source folders you added on Source Packages Folders panel with binaries (JAR or folder with \*.class files), that are produced from those sources. However, currently you don't have probably any, because you have only sources and you did not build anything. So for now invoke Finish, you'll get back to this later.
  7. Busting error badges
    • If you haven't set up all dependencies correctly, you see probably a lot of error badges on your project file. The only way how to get rid of them is to add libraries on Java source classpath (this is acessible from project properies). The correct way how to do this is to take a look into build.xml file to examine classpath. Another approach is to look at import statements in \*.java files, and try to match them with content of lib folder (and add those matching JARs to Java source classpath). After a few iterations of adding library JAR files to Java source classpath should be red error badges gone.
  8. Binding project output
    • Invoke Build. If you set up target binding correctly, build action should be invoked on Ant script and should produce binaries. In our sample case are \*.class files compiled under build folder. Go to project properties, and set build folder as output for your sourceroot. This is an important thing, if you are going to use debugging or you want some other project depend on your project.
      Now your project should be set up correctly. Note that this is not any generic manual how to set up every existing project as NetBeans free-form project. But it should get some insight of possible workflow during setting thing up for newbies :)

thank u r information

it very useful

u r blog Is very nice

Posted by Matthew on October 16, 2008 at 08:53 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed

Team blog of NetBeans Core and Platform Quality Assurance team


« July 2016