Products sharing a common source framework

The Java source files for two products require a common framework:

Layout 4

  1. Select the menu item File > New > Project.... to open the New Project wizard.
  2. On the left pane of the first wizard page, select Java, and on the right pane, select Java Project. Click Next.
  3. On the next page, type "Product1" in the Project name field. Click Next.

    Source and output folders page

  4. Select "Product1" source folder and click Edit....
  5. Click Create New Folder.... Type "JavaSourceFiles" in the Folder name field.
  6. Click Advanced. Check Link to folder in the file system. Click Browse.... and choose the "JavaSourceFiles" directory in "Product1".

    Source and output page after setting output

  7. Click OK twice to close the two dialogs.
  8. Click Add Folder....
  9. Click Create New Folder.... Type "src-common" in the Folder name field.
  10. Click Advanced. Check Link to folder in the file system. Click Browse.... and choose the "JavaSourceFiles" directory in "CommonFramework".

    Source and output page after setting output

  11. Click OK twice to close the two dialogs.
  12. Type "Product1/bin" in the Default output folder field.

    Source and output page after setting output

  13. Click Finish.
  14. Repeat these steps for "Product2".
  15. You now have two Java projects which respectively contain the sources of "Product1" and "Product2" and which are using the sources of "CommonFramework".

    Java perspective

Note: Files in "src-common" are shared. So editing "Common.java" in "Product1" will modify "Common.java" in "Product2". However they are compiled in the context of their respective projects. Two "Common.class" files will be generated; one for each project. If the two projects have different compiler options, then different errors could be reported on each "Common.java" file.

Related concepts

Java projects
Java views

Related tasks

Working with build paths
Creating a new Java project
Creating a Java project with source folders
Creating a new source folder
Using the Package Explorer

Related reference

New Java Project Wizard
Package Explorer View

Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.