站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Building and Running Java PathFinder with NetBeans

Building and Running Java PathFinder with NetBeans

摘要: This document illustrates how easy it is to get a NetBeans development environment up and running for the Java PathFinder SourceForge.net project. As you will read in this document, using NetBeans as the development tool for building and running Java PathFinder is very simple.

Getting Started

To get started you will first need to set up your environment. Once you have verified that your environment is set up correctly you will be ready to get the Java PathFinder source files, build it, and run it from NetBeans.

The instructions in this document are presented from a Windows user's perspective. Solaris and Linux users should substitute path names, installation program names, etc. for their platforms where applicable.

Setting up your environment

Before you can build and run Java PathFinder, you need to install a few additional components. The simplest way to do this is to download all of the components and then install them in the order listed below.

Download the components

Note: The installation instructions assume that you download all of the components into C:\tmp.

  1. Java 2 SDK, Standard Edition 1.4.2 or 1.5.0 or later if you do not already have one installed.
    http://java.sun.com/j2se/1.5.0/download.jsp

    Note: The installation instructions below assume you download the Windows version of the JDK.

  2. NetBeans 4.1 IDE if you do not have NetBeans installed
    http://www.netbeans.info/downloads/download.php?type=4.1rc1

    Note: Unless you are planning to do J2EE development, you can download the NetBeans 4.1 RC installer, (netbeans-4_1-rc1-windows.exe) version.

  3. Java PathFinder Convenience Libraries
    http://sourceforge.net/project/showfiles.php?group_id=136825&package_id=151191&release_id=323978

    This is a single file, jpf-lib.zip, that contains .jar files needed by Java PathFinder.

Install the Components

After downloading all of the components, install them by following the instructions below.

  1. If you have not already installed a 1.4.2 or 1.5.0 or later JDK, install the Java 2 SDK:

    Go to the C:\tmp directory where you downloaded the JDK and double click the jdk-1_5_0_02-windows-i586-install.exe file to initiate the installation of the JDK. Follow the instructions given by the JDK installer to install the JDK.

  2. If you do not already have NetBeans installed, install the NetBeans IDE:

    Go to the C:\tmp directory where you downloaded NetBeans and double click the netbeans-4_1-rc1-windows.exe file to initiate the installation of NetBeans. Follow the instructions given by the NetBeans installer to install NetBeans.

Now that you have the necessary environment to build Java PathFinder, you are ready to launch NetBeans, get the Java PathFinder source code, build Java PathFinder from source and run Java PathFinder all from within NetBeans.

Launching NetBeans

To launch NetBeans, double click the NetBeans 4.1 icon on your desktop. Or, if you are on Solaris or Linux, launch NetBeans by typing netbeans in a terminal window.

Getting the Java PathFinder Source Code

The next step is to configure the NetBeans IDE to retrieve the Java PathFinder source code from the sourceforge.net CVS repository.

In the NetBeans IDE, from the main menu select Versioning > CVS > Check Out as shown in Figure 1 below.

Versioning > CVS > Check Out

Figure 1 Versioning > CVS > Check Out

After you have selected the Versioning > CVS > Check Out menu item, the you will see the "Enabling Advanced CVS Command Options" dialog as shown in Figure 2.

Figure 2 Enabling Advanced CVS Command Options

Figure 2 Enabling Advanced CVS Command Options

If you do not want to see this dialog in the future, go ahead and mark the checkbox next to the label "Do Not Show This Dialog Box Again" as shown in Figure 2 above and press the "Check Out" button.

Next you will see the "CVS Checkout" dialog. There are several values you will need to enter on this screen. Each of the values below should be entered in this screen.

    Working Directory: <source path where to place Java PathFinder source files>

Remember this directory path, you will need to know it again later

    CVS Server Type: pserver
    CVS Server Name: cvs.sourceforge.net
    Port: 2401
    User Name: anonymous
    Repository Path: /cvsroot/javapathfinder

Select "Use Built-in CVS Client"

    Password: <leave this blank>

Leave the Modules and Revision fields blank

    Module(s): <leave this blank>
    Revision or Tag: <leave this blank>

Your CVS Checkout form should look very similar to the one shown in Figure 3 below.

Figure 3 CVS Checkout

Figure 3 CVS Checkout

You need to login if you see the message "You are not logged in." below the Password field and Login button. If you see this message, Press the Login button now. The label will change to "You are logged in" as shown in Figure 3 above.

The CVS Checkout form from my development environment is shown in Figure 4 below.

Figure 4 CVS Checkout logged in

Figure 4 CVS Checkout logged in

Once you have the CVS Checkout form completed and it says you are logged in, press the "Ok" button.

After you have pressed the "Ok" button, the CVS Checkout form will go away and you will notice the output window, the bottom portion of the NetBeans IDE, will display the VCS Output from running your CVS checkout. The output in this VCS Output window should look very similar to that shown in Figure 5 below.

Figure 5 VCS Output Window - click for fullsize

Figure 5 VCS Output Window

When the CVS checkout is completed, the status message at the bottom of the VCS Output window will say it has finished the Check Out.

Installing the Java PathFinder Convenience Libraries

Now that a folder for the Java PathFinder source is on your system, you will next unzip the jpf-lib.zip file.

When you specified a working directory for the CVS Checkout, NetBeans created a javapathfinder folder in that working directory. That javapathfinder folder contains a lib folder. The lib folder is where PathFinder's build.xml expects to find these three .jar files: bcel.jar, fast-MD5.jar, and xercesImpl.jar. Unzip the contents of jpf-lib.zip to your javapathfinder folder.

Setting up a Java PathFinder Project in NetBeans

Now that you have the Java PathFinder source files locally on your system, you will next create a NetBeans project to build and run Java PathFinder.

Select File > New Project from the main menu as shown in Figure 6 below.

Figure 6 Creating a new project

Figure 6 Creating a new project

After selecting the File > New Project menu item, a New Project wizard will be displayed as shown in Figure 7.

Figure 7 New Project Wizard

Figure 7 New Project Wizard

In the New Project wizard, select the General project category and Java Project with Existing Ant Script project type as shown above in Figure 7. Then, press the Next button. This will bring up the second screen of the New Project wizard. On this form you specify the location of the project files, the Ant build script, supply a project name and a project folder.

For the Location field, browse to the directory you specified as the working directory earlier when you told NetBeans to download the source files for Java PathFinder and select the "javapathfinder" directory as the location of the Java PathFinder source file location. The NetBeans IDE will automatically find the Ant build script and specify a project name and project folder. You can accept the defaults NetBeans has chosen for the project name and project folder or change them if you wish.

An example screen shot of the values used in my development environment along with the default values NetBeans automatically filled in for the project name & project folder is shown in Figure 8 below.

Figure 8 Project Name and Location - click for fullsize

Figure 8 Project Name and Location

After selecting the project name and location, press the Next button. This will take you to the Build and Run Actions form of the New Project wizard. You will notice that NetBeans will automatically map Ant build targets to NetBeans actions. An example of the mapping NetBeans has automatically chosen are shown in Figure 9 below.

Figure 9 Build and Run Actions

Figure 9 Build and Run Actions

Press the Next button to accept the default mappings. (Note: You can change any of the default mappings by simply selecting one of the dropdown boxes and selecting a different Ant build target.)

After pressing the Next button, the Source Package Folders form of the New Project wizard is displayed. On this form you specify the source directories for your project. To add the source package folder click on the Add Folder button in the Source Package Folder section of this form. Traverse to the directory you specified earlier as the Working Directory in the CVS form and open the javapathfinder directory. Then, select and open the src folder. Then, add the test package folder by pressing the Add Folder button in the Test Package Folders section of the wizard. Traverse to the directory you specified earlier as the Working Directory in the CVS form and open the javapathfinder directory. Then, select and open the test folder.

The last thing to set on this form is the Source Level. Set the source level to JDK 1.4 by selecting the Source Level dropdown box and choosing JDK 1.4.

Your Source Package Folders wizard should look like the one shown in Figure 10 below.

Figure 10 Source Package Folders

Figure 10 Source Package Folders

Press the next button to go to the Java Sources Classpath form. On this form you tell NetBeans where to find the three additional components (BCEL, Xerces and MD5) to be used by the editor for tasks such as syntax checking, code completion and import statements. The .jar files for these three components are located in the javapathfinder/lib folder.

Add each of the three components on this form. An example screen for after adding these three components for my development environment is shown in Figure 11 below.

Figure 11 Java Sources Classpath

Figure 11 Java Sources Classpath

After adding the three components, press the Finish button.

You will now notice in the NetBeans project window a new project is shown. Your NetBeans project window should look like to the one shown in Figure 12.

Figure 12 NetBeans Project Window

Figure 12 NetBeans Project Window

You now have successfully created and configured a Java PathFinder project in NetBeans. You are now ready to build and run Java PathFinder in NetBeans.

Building & Running the Java PathFinder Project in NetBeans

In the NetBeans project window, right click on the newly created Java PathFinder project. You can choose to build the project which will compile the Java PathFinder project or you can choose to run the project which will both build the project and run the Java PathFinder test suite.

When you right click on the Java PathFinder project in the project's window, you can see options such as those shown in Figure 13 below.

Figure 16 Run Java PathFinder project

Figure 13 Run Java PathFinder project

Select, "Run Project", as shown in Figure 13 to run the project. This will initiate a build of the Java PathFinder project if it has not already been built and run a suite of tests after it is built. You will notice in the bottom of the NetBeans IDE, the output window will show the results of building and running the Java PathFinder project. An example of the NetBeans output window from building and running the Java PathFinder project is shown in below.

Figure 14 NetBeans Output Window - click for fullsize

Figure 14 NetBeans Output Window

That's all there is to having an environment where you can build and run the Java PathFinder in NetBeans. Simple isn't it?


↑返回目录
前一篇: Blackberry Development Using NetBeans Mobility
后一篇: Building and Running Project Looking Glass with NetBeans