当前页面: 开发资料首页 → Netbeans 专题 → Developing and Building Project GlassFish with NetBeans
摘要: Project GlassFish, Sun's open source application server development effort on Java.net, has already been set up to work with NetBeans. Each of the 30 modules that comprise project GlassFish have been set up as a NetBeans project. This article will show you how to set up your environment in order to edit, build and run project GlassFish using NetBeans. In addition, I show you how to modify the project settings and set up new modules if the need arises. For full details on the steps referenced in this document, please see complete set of instructions on how to build GlassFish.
For this exercise, we'll make a modification to the admin-cli project.
There are about 30 modules that make up project GlassFish, each of which has been set up for you as a NetBeans project of type Free-Form Project. Since the Free-Form Project type is designed for projects with an existing Ant script, NetBeans creates an ancillary file called project.xml to:
You'll find the project.xml file in a subdirectory called nbproject.
To learn more about this project type, see Advanced Free-Form Project Configuration.
These directories are configured in the project's Java Sources properties.
The NetBeans editor does not pull the classpath information from the Ant build script. Although the module will build, it will not look pretty in the editor. For example, here's the S1ASCommand.java before the classpath was configured.
The GlassFish build scripts use the libraries from the extracted GlassFish image for its classpath. The location for these libraries is configured in the glassfish module's project.properties file (we checked out the glassfish module above when we got the source).
Like the build target and source root configuration, this can also be done via the project's property editor. However, using the property editor would set absolute paths to required libraries, therefore, we've manually edited the project.xml file so we could reference the glassfish/project.properties when configuring the editor's classpath.
First, we import the glassfish/project.properties into the project.xml file.
Then you reference glassfish/project.properties that map to jar files. Note that each source root has its own classpath. So in the example below, the sources in the cli-api/src/java have no other dependencies. However, the sources in commands/src/java depend on classes in admin-cli.jar, appserv-admin.jar and appserv-rt.jar.
If, while working in any of the GlassFish modules, you have unresolved compiler errors in the NetBeans editor, its a matter of simply adding the missing jar files to the classpath.
Note, the properties to resolve nicely when viewed from the NetBeans Project Property editor.
To learn more about this project type, see Advanced Free-Form Project Configuration.