EclipseWorkspaceImporterDemo

Eclipse Workspace Importer Demo

This demo script is part of the NetBeans World Tour 2008 session #2, Using NetBeans For Your Existing Projects. It shows how to import an Eclipse project with multiple dependencies into NetBeans. The project structure is as follows:

Image:Graphic_EclipseWorkspaceImporterDemo.png

ProjA and ProjB are eclipse projects. External Library, User Library and Variable Reference are JAR files referenced using the various alternatives provided by Eclipse.

Main Points to Hit

  • Eclipse projects, including their dependencies, can be imported into NetBeans

Prerequisites

  • JDK5 or JDK6
  • NetBeans 6.0.
  • The NetBeans Eclipse Project Importer plugin, available on the update center.
  • Eclipse 3.3 (Europa)

Setup

  • Download and extract this Archive.zip. It contains 4 projects and 3 jars (the jars contain the source if needed):
  • ProjA
  • ProjB
  • ProjC
  • ProjD
  • ExternalJAR.jar
  • VariableReference.jar
  • UserLibrary.jar
  • Import the 4 projects into your Eclipse workspace (File > Import > General > Existing Projects into Workspace. Use the Select root directory option and select the archive's parent directory - Eclipse will find all 4 projects. Make sure copy projects into workspace is selected.)
  • Configure the Workspace Build Path
  • Open the Eclipse Preferences
  • Select Java > Build Path > Classpath Variables
  • Click New and create a variable named VariableReference pointing to the location you extracted the VariableReference.jar
  • Select Java > Build Path > User Libraries
  • Click New and create a user library named UserLibrary.
  • Click Add JARs and add the UserLibrary.jar from the extracted archive.
  • Correct ProjC's External JAR reference
  • Right-click ProjC and select Build Path > Configure Build Path
  • Select the Libraries tab
  • Select the ExternalJAR.jar entry. Click Edit and point to the extracted ExternalJAR.jar.
  • Run each project to test the configuration (they are all Java Applications). The output from each should be:
  • I am ProjA
  • I am ProjB
  • I am ProjC which depends on ProjA and ProjB and ExternalJAR and VariableReference and UserLibrary
  • I am ProjD which depends on ProjC which depends on ProjA and ProjB and ExternalJAR and VariableReference and UserLibrary


Demo Steps

  1. Show the projects in Eclipse, including the configured dependencies.
  2. Run each project to show its output.
  3. Switch over to NetBeans
  4. Select File > Import Project > Eclipse Project. SC: "Now let's use those Eclipse project definitions to create the same projects in NetBeans."
  5. Select the Import Projects from Workspace option and select your Eclipse Workspace directory.
  6. Select ProjC, notice how ProjA and ProjB, but not ProjD, are also selected.
  7. If you select ProjD, which will select C, B and A, and click Finish to import all 4 projects.
  8. Run each project in succession.
  9. Everything is great until you try to run ProjD. Unlike Eclipse, NetBeans does not recognize nested project dependencies. This is one of the big complaints for developers trying to move to NetBeans. Every new project that depends on ProjC also has to know about its dependent projects. In Eclipse, if you were to add ProjNew as a dependency to ProjC, ProjD would pick this up automatically - no so with NetBeans. See issue 125869.


Editing Code

  1. In Eclipise, edit ProjA.java such that getId() returns "ProjA Updated". Save the file, run ProjC and notice that it has correctly picked up the updated ProjA.
  2. Return to NetBeans. ProjC will not pick up the change to ProjA until ProjA is built again. See issue: 125870


Demo Cleanup

  • Delete the NetBeans projects, but keep the source.

References

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo