Products sharing a common source framework

Layout on file system

Steps for defining corresponding projects

  1. Open a Java perspective, select the menu item File > New > Project.... to open the New Project wizard.

  2. Select Java project in the list of wizards and click Next.

  3. On the next page, type "Product1" in the Project name field. Click Next.

    Layout 41

  4. On the next page, Select "Product1" source folder.

    Click Link Additional Source to Project button Link Additional Source to Project in view bar.

    Layout 42

  5. In Link Additional Source click Browse.... and choose the D:\Product1\JavaSourceFiles directory.

    Type "src" in the Folder name field.

    Layout 31

  6. Click OK to close the dialog.

  7. Click OK in confirmation dialog to have "Product1/bin" as default output folder.

    Layout 12

  8. Your project source setup now looks as follows:

    Layout 43

  9. Click Finish.
  10. Edit project "Product1"properties and select Java Builder Path page.

    On Source tab, click Add Folder....

    Layout 33

  11. On Source Folder Selection click Create New Folder....

    Layout 44

  12. In New Folder, type "src-common" in the Folder name field.

    Click Advanced>> and check Link to folder in the file system.

    Then click Browse.... and choose the D:\Framework\JavaSourceFiles directory.

    Layout 45

  13. Click OK twice to close dialogs.

  14. Your project setup now looks as follows:

    Layout 46

  15. Click OK.
  16. Repeat these steps for "Product2".

  17. You now have two Java projects which respectively contain the sources of "Product1" and "Product2" and which are using the sources of "Framework".

    Layout 47

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