Importing a Project Developed in a Different Environment


If you have a project you have been working on in a different development environment, you can "import" the project into NetBeans IDE using a "With Existing Sources" project template.

When you import a project, you point the IDE to the folders for your sources and your tests (they are not copied), and create a folder that holds metadata for the project. Following are procedures for importing a general Java application and importing a web application. If you want to import a project developed in Eclipse or JBuilder, you can use special importing tools for those projects. See the appendices at the end of the book.

To import a Java application that was created in a different environment:

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

  2. In the Categories tree, select the General folder.

  3. Select Java Project with Existing Sources and click Next.

  4. On the Name and Location page of the wizard, fill in the following fields (or verify the generated values):

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

    Project Folder. The location of the project's metadata. By default, the IDE places this folder with your project sources, but you can designate a different location.

  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. On the Existing Sources page of the wizard (as shown in Figure 3-4), enter the location of your sources by clicking the Add Folder button next to the Source Package Folders field and navigating to the root of your sources. For example, the root folder might be called src.

    Figure 3-4. New Project wizard, Existing Sources page for Java project with existing sources

    If you have multiple source root folders, repeat this step for each source root. Note, however, that sources added in this manner can be added to only one project (though this limitation might disappear after NetBeans IDE 5.0).

  7. In the Test Packages Folder field, enter the folder that contains the default package of your unit tests (for example, the folder might be called tests).

    If you have multiple test root folders, repeat this step for each source root. You can leave this field blank if you have no unit tests.

  8. Click Finish.

To import a web application that you have begun developing in a different environment:

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

  2. In the Categories tree, select the Web folder.

  3. Select Web Application with Existing Sources and click Next.

  4. On the Name and Location page of the wizard, fill in the following fields (or verify the generated values):

    Location. The folder that contains your web pages and sources. If you have multiple source roots, you can fill those in later.

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

    Project Folder. The location of the project's metadata.

    Server. The server on which you plan to deploy the application. 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.

  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. 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.

    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. Click Next.

  8. In the Existing Sources and Libraries page (as shown in Figure 3-5), fill in or verify the contents of the following fields:

    Web Pages Folder. The folder that contains your web pages. This field should be filled in automatically, based on what you specified in the Location field of the wizard's Name and Location page.

    Libraries Folder. The (optional) folder that contains any libraries specifically for this project, such as tag libraries.

    Source Package Folders. The folder (or folders) that contains your sources. This field should be filled in automatically, based on what you specified in the Location field of the wizard's Name and Location page and should contain the default Java package for the project (for example, the folder might be called src). You can click Add Folder to add additional source roots. However, you can add each source root to only one NetBeans IDE 5.0 project.

    Test Package Folders. The folder (or folders) that contains any unit tests you have written for your sources. You can click Add Folder to add additional test roots.

    Figure 3-5. New Project wizard, Existing Sources and Libraries page for Web Application with Existing Sources template

  9. Click Finish.

For more complex projects that require a lot of classes, it might work best to use the web application project as the main project and configure it to depend on Java Library projects that handle most of the processing in your application. For applets and tag libraries, it is necessary to use Java Library projects to get them to work within your web application. See Chapter 8.




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