How to link project in eclipse

2019-01-18 22:05发布

问题:

I have a java project and I want to develop it without replacing the source code from its place. I want to link my code to my workspace without replace physically?

回答1:

  1. Select the Project you want to reference from on Package Explorer
  2. Right-click and go to Properties ( or hit Ctrl-Enter ).
  3. Under Projects in Java Build Path you can add another project which is currently open.

If you want to override a class you can make a copy of it in your current project and move it further up in the classpath in Order and Export.



回答2:

Linking Source

Project properties -> Java build path (tree-item) -> Source (tab) -> Link source (button)

Linking Projects

Project properties -> Java build path (tree-item) -> Projects (tab) -> Add... (button)

Suggestion

See Eclipse help topic: Workbench User Guide > Tasks > Working with projects, folders and files > Creating linked resources.



回答3:

You can link to a project that exists outside your workspace. This allows the project to continue to exist outside but be referable for purposes of browsing source, debugging, breakpoints, etc. In Eclipse, from the menu:

  1. Select File | Import... and choose General > Existing Projects into Workspace
  2. On the next panel in the dialog, browse to the location of the project and ensure it's selected in the listbox.
  3. Be sure to not check the checkbox Copy projects into workspace. Click Finish.

Changes you make in the project in this workspace will be reflected into the project in it's native location.

Be sure that when you remove the project reference from the non-natively owned workspace, that you don't Delete project contents on disk (cannot be undone).