| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | |
| <!-- Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. --> | |
| <!-- Use is subject to license terms.--> | |
| <head> | |
| <title>Importing Eclipse Projects into NetBeans IDE - Tutorial</title> | |
| <meta name="KEYWORDS" content="NETBEANS, TUTORIAL, GUIDE, USER, DOCUMENTATION"> | |
| <meta name="description" | |
| content="Overview of Eclipse Import features in NetBeans IDE"> | |
| <link rel="stylesheet" href="../../../netbeans.css"> | |
| </head> | |
| <body> | |
| <a name="top"></a> | |
| <h1>Importing Eclipse Projects into NetBeans IDE</h1> | |
| <p><b>Contents</b></p> | |
| <img src="../../../images_www/articles/72/netbeans-stamp-74-73-72.png" class="stamp" alt="Content on this page applies to NetBeans IDE 6.9, 7.0, 7.1, 7.2, 7.3, and 7.4" title="Content on this page applies to the NetBeans IDE 6.9, 7.0, 7.1, 7.2, 7.3, and 7.4"> | |
| <ul class="toc"> | |
| <li><a href="#intro" title="The Import Eclipse Project Wizard">The Import Eclipse Project Wizard</a></li> | |
| <li><a href="#how-it-works" title="How the Import Wizard Works">How the Import Wizard Works</a></li> | |
| <li><a href="#import" title="Importing and Configuring Projects">Importing and Configuring Projects</a></li> | |
| <li><a href="#build" title="Building and Running a Project">Building and Running a Project</a></li> | |
| <li><a href="#metadata" title="NetBeans Project Files">NetBeans Project Files</a></li> | |
| <li><a href="#versioning" title="Version Control Considerations">Version Control Considerations</a></li> | |
| <li><a href="#resynch" title="Resynchronizing a Project">Resynchronizing a Project</a></li> | |
| <li><a href="#problems" title="Resolving Import Problems">Resolving Import Problems</a></li> | |
| <li><a href="#nextsteps" title="See Also">See Also</a></li> | |
| </ul> | |
| <p><b>To complete this tutorial, you need the following software and resources.</b></p> | |
| <table> | |
| <tbody> | |
| <tr> | |
| <th class="tblheader" scope="col">Software or Resource</th> | |
| <th class="tblheader" scope="col">Version Required</th> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1"><a href="http://www.netbeans.org/downloads/index.html">NetBeans IDE</a></td> | |
| <td class="tbltd1">version 6.9, 7.0, 7.1, 7.2, 7.3, or 7.4 </td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1"><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit (JDK)</a></td> | |
| <td class="tbltd1">version 6 or 7</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <a name="intro"></a><h2>The Import Eclipse Project Wizard</h2> | |
| <p>An enhanced support for importing Eclipse projects is available in the NetBeans IDE. The Import Eclipse Project wizard enables you to use NetBeans to work on Java desktop and web | |
| application projects that were created in Eclipse and MyEclipse.</p> | |
| <p>After creating a NetBeans project from an Eclipse project, you can work | |
| in the following ways:</p> | |
| <ul> | |
| <li>Use NetBeans on a team project where other developers are using Eclipse. | |
| </li> | |
| <li>Use NetBeans and Eclipse interchangeably on a project. | |
| </li> | |
| <li>Try out NetBeans on an existing project that was set up in Eclipse. </li> | |
| </ul> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <a name="how-it-works"></a><h2>How the Import Wizard Works</h2> | |
| <p>When you import a project, the IDE analyzes the Eclipse project metadata and then | |
| creates a NetBeans project based on that metadata. The project import | |
| does not impose changes on the Eclipse project | |
| structure, so it does not interfere with the way the project works in Eclipse.</p> | |
| <p>Once you have the project | |
| imported, you can use either or both the NetBeans and Eclipse IDEs to | |
| edit, build, run, debug, and profile the project. | |
| If you make a configuration change in the Eclipse project, you can resynchronize | |
| the NetBeans project. This enables you to work on projects in NetBeans even | |
| if everybody else on your team is working with Eclipse. | |
| The build path that you set in Eclipse remains the master build path for the project.</p> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <h2><a name="import"></a>Importing and Configuring Projects</h2> | |
| <p><b>To import an Eclipse project into the IDE:</b></p> | |
| <ol> | |
| <li>Make sure that you have copy of the project that you want to import on your system. | |
| <p>Typically, this project would already be in an Eclipse workspace on your | |
| system.</p></li> | |
| <li>Choose File > Import Project > Eclipse Project.</li> | |
| <li>In the Workspace Location page of the wizard, select the Import Projects from Workspace radio button and specify the workspace location. Click Next. | |
| <p class="align-center"><a href="../../../images_www/articles/71/java/import-eclipse/eclipse-import-workspace-location.png" rel="lytebox" title="The Workspace Location page of the Import Eclipse Project wizard - Click to enlarge"> | |
| <img src="../../../images_www/articles/71/java/import-eclipse/eclipse-import-workspace-location-small.png" alt="The Workspace Location page of the Import Eclipse Project wizard " border=1></a></p></li> | |
| <li>In the Projects to Import page, select the projects that you want to | |
| import.</li> | |
| <li> Choose one of the following two options for storing the NetBeans project | |
| files: | |
| <ul> | |
| <li><b>Store NetBeans project data inside Eclipse project folders.</b> | |
| NetBeans adds folders and files within the top-level folder of the original | |
| project.</li> | |
| <li><b>Create imported NetBeans projects in a separate location.</b> | |
| NetBeans uses the sources and libraries in the | |
| original Eclipse project folder but creates a separate folder to hold | |
| NetBeans project metadata and build outputs.</li> | |
| </ul> | |
| <p class="notes"><b>Note:</b> Typically, it is better to store NetBeans project data inside | |
| Eclipse project folders. In most cases, this means that the NetBeans project | |
| metadata will refer to sources and libraries with the same paths that are used by | |
| the Eclipse metadata. Therefore, checking out the project from a version | |
| control system on different machines should result in similar behavior | |
| both in NetBeans and Eclipse.<br> | |
| See <a href="#metadata">NetBeans Project Files</a> below for a list of files and | |
| folders that the NetBeans IDE creates.</p> | |
| </li> | |
| <li>(Applicable when web applications are being imported only.) Click Next. In the Servers page, register any servers that your projects need with | |
| NetBeans IDE.</li> | |
| <li>Click Finish.</li> | |
| </ol> | |
| <p>After you have completed the wizard, the following dialog boxes might appear:</p> | |
| <ul> | |
| <li><b>Import Issues.</b> This dialog box provides information about discrepancies | |
| between the project structure in Eclipse and in NetBeans and points out | |
| actions that you might need to take to correct the discrepancies. | |
| <br>You can copy the information from this dialog and paste it elsewhere for future reference. | |
| <br>In most cases, you use the project's Project Properties dialog box to | |
| resolve those issues. See <a href="#problems">Resolving Import Problems</a> | |
| for a guide to resolving the most common problems. | |
| <p class="align-center"><a href="../../../images_www/articles/71/java/import-eclipse/eclipse-import-issues.png" rel="lytebox" title="The Import Issues dialog box - Click to enlarge"> | |
| <img src="../../../images_www/articles/71/java/import-eclipse/eclipse-import-issues-small.png" alt="The Import Issues dialog box" border=1></a></p> | |
| </li> | |
| <li><b>Resolve Reference Problems.</b> This dialog box alerts you to a specific | |
| reference problem with one of your project libraries. You can solve this problem | |
| after dismissing this dialog box by right-clicking the project's node and | |
| choosing Resolve Reference Problems.</li> | |
| <li><b>Resolve Missing Server.</b> This dialog box alerts you that the | |
| project can not find a necessary server. You can solve this problem | |
| after dismissing this dialog box by right-clicking the project's node and | |
| choosing Resolve Missing Server.</li> | |
| </ul> | |
| <p>After you have completed the wizard and have closed any of the above | |
| informational dialog boxes, nodes for the projects will appear in the Projects window. | |
| </p> | |
| <p class="align-center"><img src="../../../images_www/articles/71/java/import-eclipse/eclipse-import-projects-window.png" | |
| alt="The Projects window after a project has been imported." class="margin-around"></p> | |
| <p>If there are references in your | |
| project metadata to servers or other resources that NetBeans can not resolve, | |
| the node for the project will appear in red. You can resolve these references | |
| immediately by right-clicking the project node and choosing Resolve Reference | |
| Problems or Resolve Missing Server.</p> | |
| <p>For other types of project configuration adjustments, you use the | |
| Project Properties dialog box. You open the Project Properties dialog box | |
| by right-clicking the project's node and choosing Properties.</p> | |
| <p>For more information on configuring your project, see | |
| <a href="project-setup.html#projects-configuring">Configuring the Classpath and Other Project Settings</a> | |
| in the Creating, Importing, and Configuring Java Projects guide.</p> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <h2><a name="build"></a>Building and Running a Project</h2> | |
| <p>Once you have the project imported into NetBeans, you can build and run the | |
| project. All artifacts created from NetBeans build and run commands are created in | |
| the <code>build</code> and <code>dist</code> folders. NetBeans does not | |
| over-write output created from Eclipse build actions. If the Eclipse project already | |
| has <code>build</code> and <code>dist</code> folders, | |
| the NetBeans project creates folders called | |
| <code>nbbuild</code> and <code>nbdist</code> and uses those for the build outputs.</p> | |
| <p>The following are some of the build and run commands are available from the Run menu:</p> | |
| <ul> | |
| <li><b>Run Project.</b> Test runs the application in the IDE.</li> | |
| <li><b>Clean and Build Project.</b> Deletes the contents of the <code>build</code> | |
| (or <code>nbbuild</code>) and <code>dist</code> (or <code>nbdist</code>) | |
| folders and rebuilds all of the project's outputs. Uses | |
| the NetBeans build script. | |
| Similar to the Clean command in Eclipse.</li> | |
| <li><b>Clean.</b> Deletes the contents of the <code>nbbuild</code> | |
| and <code>nbdist</code> folders.</li> | |
| <li><b>Build.</b> Rebuilds the project's outputs. If the Compile on Save | |
| feature is enabled, the Build command is disabled. See the | |
| <a href="project-setup.html#building-compile-on-save">Compile on Save</a> section | |
| of the Creating, Importing, and Configuring Java Projects guide.</li> | |
| </ul> | |
| <p>For more information on building and running your application as well as | |
| customizing the build process, see | |
| <a href="project-setup.html">Creating, Importing, and Configuring Java Projects</a>. | |
| </p> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <h2><a name="metadata"></a>NetBeans Project Files</h2> | |
| <p>After you have imported the project, you will find the following folder and files | |
| on your system:</p> | |
| <ul> | |
| <li><code>build.xml</code> file or <code>nb-build.xml</code> file. The main NetBeans build | |
| script for the project. You can customize this script according to the needs | |
| of your project. By default, this file is called <code>build.xml</code>. | |
| If such a file already exists in the project folder, the script is called | |
| <code>nb-build.xml</code>.</li> | |
| <li><code>nbproject</code> folder. Contains most of the NetBeans project metadata, | |
| including resources that are called by the main NetBeans build script. If you check | |
| this folder and the <code>build.xml</code> file or <code>nb-build.xml</code> | |
| into your version control system, other users will be able to | |
| open the project in NetBeans. This folder also contains the <code>private</code> | |
| folder, which contains data specific to your system. This folder should not | |
| be checked in to the version control system since its contents will vary | |
| between users. See <a href="#versioning">Version Control Considerations</a> below.</li> | |
| <li><code>nbbuild</code> folder. When you build or run your project in NetBeans, | |
| the project's sources are compiled into this folder.</li> | |
| <li><code>nbdist</code> folder. When you build your project in NetBeans, | |
| the project's distributable outputs are created and placed in this folder. | |
| Such outputs might be JAR files and WAR files.</li> | |
| </ul> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <a name="versioning"></a><h2>Version Control Considerations</h2> | |
| <p>If the project is checked out of a version control system, | |
| the <code>build</code> (or <code>nbbuild</code>), | |
| <code>dist</code> (or <code>nbdist</code>), and the <code>nbproject/private</code> | |
| folders should not be checked into that version control system. </p> | |
| <p>If the project | |
| is under the CVS, Subversion, or Mercurial version control systems, the | |
| appropriate "ignore" files are created or updated for these directories when | |
| the project is imported.</p> | |
| <p class="notes">Though <code>nbproject/private</code> should be ignored, | |
| <code>nbproject</code> should be checked into the version control system. | |
| <code>nbproject</code> contains project metadata that enables others users to | |
| open the project in NetBeans without having to import the project first.</p> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <h2><a name="resynch"></a>Resynchronizing a Project</h2> | |
| <p>The project importer features synchronization capabilities. If | |
| the classpath in the Eclipse has changed since you initially imported it, you can | |
| use the Resynchronize Eclipse Projects feature to update the classpath | |
| in the corresponding NetBeans project.</p> | |
| <p>Project resynchronization is one-way from Eclipse projects to NetBeans projects. | |
| If you make changes to the project structure in NetBeans, those changes are not | |
| propagated to the Eclipse project with the resynchronization feature. | |
| If you intend to keep both Eclipse and NetBeans projects, use the Eclipse project | |
| as the "master" project.</p> | |
| <p>The IDE also resynchronizes the projects automatically if the changes to the | |
| Eclipse configuration are unambiguous and do not require your input. This | |
| automatic resynchronization occurs shortly after you open the project. | |
| If the resynchronization requires your input, you need to manually | |
| resynchronize the project.</p> | |
| <!-- TODO add information on what gets synchronized--> | |
| <p><b>To manually resynchronize NetBeans projects with Eclipse projects:</b></p> | |
| <ul> | |
| <li>Choose File > Import Project > Resynchronize Eclipse Projects.</li> | |
| </ul> | |
| <p class="notes"><b>Notes:</b> When you resynchronize a project, the resynchronization | |
| is performed on all projects that you have imported from the workspace.</p> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <h2><a name="problems"></a>Resolving Import Problems</h2> | |
| <p>When you import a project into NetBeans, there might be some things that can | |
| not be automatically resolved in NetBeans IDE. For some of these problems, | |
| a menu item, such as Resolve Missing Server Problem, appears in the contextual menu for the project. | |
| Other problems can be resolved | |
| in the Project Properties dialog box for the imported project in NetBeans IDE. | |
| </p> | |
| <p>Here is a list of common import problems and their solutions.</p> | |
| <table> | |
| <tr> | |
| <th class="tblheader" scope="col">Problem Message</th> | |
| <th class="tblheader" scope="col">Solution</th> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Resolve Missing Server Problem</td> | |
| <td class="tbltd1">Right-click the project node and choose Resolve Missing Server Problem. | |
| Then navigate to the file or folder that contains the server.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Resolve Reference Problem</td> | |
| <td class="tbltd1">Right-click the project's node and choose Resolve Reference | |
| Problem. Then navigate to the file or folder that contains the resource that | |
| is referred to from the project.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Eclipse platform for project <i>ProjectName</i> cannot be used. | |
| It is a JRE and the NetBeans project requires a JDK. NetBeans will use the default platform. | |
| </td> | |
| <td class="tbltd1">If you would like to change the platform that NetBeans uses | |
| for the project, choose Tools > Platforms and specify a different platform.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Eclipse project <i>ProjectName</i> claims to use JDK from the "{1}" directory. But this directory does not exist. NetBeans will use the default platform. | |
| </td> | |
| <td class="tbltd1">If you would like to change the platform that NetBeans uses | |
| for the project, choose Tools > Platforms and specify a different platform.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">NetBeans does not support source includes/excludes per | |
| source root as Eclipse does. They were merged and it is recommended that | |
| you double check them in project's properties in Source panel. | |
| </td> | |
| <td class="tbltd1">In NetBeans, includes and excludes are declared in one | |
| place for the whole project. To check the includes and excludes in the | |
| NetBeans project, right-click the project's node and the Projects window | |
| and choose Properties. In the Project Properties dialog box, select the | |
| Sources tab and then click the Includes/Excludes button.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Import failed due to <i>...</i>. More details can be found in IDE's log file.</td> | |
| <td class="tbltd1">You can open the IDE's log file by choosing View > IDE Log.</td> | |
| </tr> | |
| <tr> | |
| <td class="tbltd1">Unknown project type - it cannot be imported.</td> | |
| <td class="tbltd1">You can only import the following Eclipse project types: | |
| Java Project, Java Project from Existing Ant File, Static Web, Dynamic Web, | |
| and JPA Project.</td> | |
| </tr> | |
| </table> | |
| <!-- TODO link to a wiki with other troubleshooting info--> | |
| <!-- ======================================================================================= --> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| <div class="feedback-box" ><a href="/about/contact_form.html?to=3&subject=Feedback:%20Importing%20Eclipse%20Projects%20into%20NetBeans%20IDE">Send Feedback on This Tutorial</a></div> | |
| <br style="clear:both;" > | |
| <h2><a name="nextsteps"></a>See Also</h2> | |
| <ul> | |
| <li><a href="http://www.oracle.com/pls/topic/lookup?ctx=nb7400&id=NBDAG445">Importing an Eclipse or JBuilder Project</a> in <i>Developing Applications with NetBeans IDE</i></li> | |
| <li><a href="http://wiki.netbeans.org/NetBeansForEclipseUsers">NetBeans For Eclipse Users</a></li> | |
| <li><a href="project-setup.html">Creating, Importing, and Configuring Java Projects</a></li> | |
| <li><a href="../../trails/java-se.html">General Java Development Learning Trail</a></li> | |
| <li><a href="../../trails/matisse.html">Java GUI Applications Learning Trail</a></li> | |
| <li><a href="../../trails/java-ee.html">Java EE & Java Web Learning Trail</a></li> | |
| </ul> | |
| <p class="align-center"><a href="#top">top</a></p> | |
| </body> | |
| </html> |