Sharing libraries

After creating a library directory, the next step is to actually share the project's library.

When projects become mature enough, or just for testing purposes, the developer can package the entire project into compressed Java Archive Files (JAR). These compressed files might be enterprise (EAR) or web (WAR) format, or simply JARs.

For this recipe, we will be using the previously created project and creating the WAR file from it.

Getting ready

If no Project is currently available at the Projects tab, follow the Creating libraries recipe to ensure that this recipe will work.

How to do it...

  1. Click on the Projects tab, or press Ctrl+1.
  2. Right-click on the project's name and click on build.

    Or

  3. Click on Files, or press Ctrl+2, to navigate to the File structure of the project.
  4. Expand the project node by double-clicking on the project's name.
  5. Right-click on build.xml.
  6. Select Run Target.
  7. On Run Target's sub menu, click on dist.
  8. The Output panel will show the path in which the WAR file is placed.

How it works...

NetBeans uses Apache Ant as the automated building system of choice.

This script is incorporated into NetBeans menus while on the Projects panel, as seen by the build menu. By clicking on build, NetBeans will call the Ant script and initiate the process of bundling all the necessary files of this project into the WAR file.

The second step-by-step is given as an example on how to access the dist target through the Files panel.

There's more...

Unsure which way to execute? And why is it good to have a separate build.xml generated by NetBeans?

File Structure or Project Structure?

The second method, though longer, is very complete in the sense that other targets can be attained, in case the dist is not necessarily what we want.

What is the advantage of a separate ANT build file?

The advantage with NetBeans build.xml is that it can be used outside the IDE as well; very useful if you are deploying the application in a machine that does not have access to a Graphical Interface. It also lets the project be packaged without the necessity of using NetBeans.

For example, sometimes the developer needs to connect remotely to some server that does not provide a graphical window manager to solve issues/bugs/introduce features. In this case, it is easy to make necessary changes, package the solution, and deploy to the application server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.59.50