Creating a Project from Scratch


If you want to start developing an application from scratch, start with the base template for the type of application you are developing. Following are procedures for creating a general Java application and a web application.

For a Java desktop application or a standard Java library to be used by other applications, do the following:

1.

Choose File | New Project (Ctrl-Shift-N).

2.

In the Categories tree, select the General folder.

3.

Select Java Application (as shown in Figure 3-2) or Java Class Library.

Figure 3-2. New Project wizard, Choose Project page


The Java Application template includes skeleton code for a main class. Use this template if you want this project to contain the entry point for your application.

The Java Library template contains no main class. Use this template if you want to create a library that is used by other applications.

4.

Click Next.

5.

Optionally, fill in the following fields on the Name and Location page of the wizard:

Project Name. The name by which the project is referred to in the IDE's user interface.

Project Location. The location of the project on your system.

The resulting Project Folder field shows the location of the folder that contains folders for your sources, test classes, compiled classes, packaged library or application, and so on.

6.

Optionally, deselect the Set As Main Project checkbox if you have another project open that you want the IDE's main project commands (such as Build Main Project) to apply to.

7.

Set the main class, using the fully qualified class name but without the .java extension (for example, com.mycompany.myapp.MyAppMain).

8.

Click Finish.

The generated project is viewable in both the Projects window and the Files window.

The Projects window provides a "logical" view of your sources and other files you are likely to edit often (such as web pages in web application projects). Project metadata (including the project's Ant build script) and project outputs (such as compiled classes and JAR files) are not displayed here.

Java source files are grouped by package instead of by folder hierarchy.

The Files window represents all the files that are in your project in folder hierarchies as they appear on your system.

For web applications, do the following:

1.

Choose File | New Project (Ctrl-Shift-N).

2.

In the Categories tree, select the Web folder.

3.

Select Web Application and click Next.

4.

Fill in the following fields (or verify the generated values) in the Name and Location panel of the wizard (as shown in Figure 3-3):

Project Name. The name by which the project is referred to in the IDE's user interface.

Project Location. The location of the project on your system.

The resulting Project Folder field shows the location of the folder that contains folders for your sources, test classes, compiled classes, packaged library or application, and so on.

Source Structure. Sets some conventions that will be used for structuring your application. If you will be deploying to Tomcat, you should choose Jakarta. If you will be deploying to Sun Java System Application Server, choose Java BluePrints.

Server. The server you plan to deploy the application to. Only servers that are registered in the IDE's Server Manager are available in the combo box. You can add additional servers (or server instances) there by choosing Tools | Server Manager in the main menu.

Figure 3-3. New Project wizard, Name and Location page for Web Application project


5.

Optionally, deselect the Set As Main Project checkbox if you have another project open that you want the IDE's main project commands (such as Build Main Project) to apply to.

6.

Optionally, adjust the following:

J2EE Version. The version of the Java EE platform your application will run against. In NetBeans IDE 5.0, versions 1.3 and 1.4 are available. Version 1.4 is preferable if you are starting from scratch, as it supports several constructs that are not recognized in version 1.3, such as tag files. However, you might need to use version 1.3 if you are setting up a project with existing sources already developed against that level.

In post-5.0 versions of the IDE, version 1.5 will be supported, which will provide features that will greatly simplify development of enterprise applications.

Context Path. The URL namespace the web application uses. For example, if the context property value is /MyWebApp, the web application is accessed from a file within http://HostName:PortNumber/MyWebApp/.

7.

If you would like to base your application on the JavaServer Faces (JSF) or Struts web frameworks, click Next and select the framework to use.

8.

Click Finish.

For more information specific to developing web applications, see Chapter 8.

If the application you are developing requires multiple outputs, you can create multiple IDE projects to accommodate them. You can connect projects by declaring dependencies in a project's Project Properties dialog box. See Creating Subprojects later in this chapter.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net