Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the right way to import Java source into Eclipse to avoid messing up references?

I created a java project and then tried to import Java source code from two different projects. I've been working on it for a few hours, deleting and re-creating the project dozens of times to try to reconcile all of the messed up references between these two projects - which other people say are supposed to work together reliably.

What I'm doing is using svn to download the source from each project. And then using File-Import-File System in Eclipse. Once it's in Eclipse, I'm using the Refactor-Move command to move everything into the same src folder. That's where I get all the red marks indicating messed up references.

What's the right way to import Java source into Eclipse to avoid messing up references?

Surely not everyone goes about it the way I am doing it - or else no one would get anything done in Eclipse. My assumption here is that I am completely clueless about Eclipse and just don't know the easy way to reconcile these two batches of compatible code.

like image 331
William Avatar asked Dec 13 '22 04:12

William


2 Answers

  1. Add the source to the project directory
  2. Right-click on project > refresh

Voila! it's there :)

like image 144
Nimo Avatar answered Jan 05 '23 00:01

Nimo


Why do they have to be the same project? You could import then into two projects and have one depend on the other. Or have them both depend on a third project. If you still want one project, you can create a new source folder for each one instead of trying to move then into a single source folder. An eclipse project can have multiple source folders. Ideally, once you got it working, you'd also want to check in the eclipse project (.project file, .settings, etc) into svn also so others can check them out directly into eclipse instead of having to import into a new project every time. It would make versioning easier.

like image 43
John Ellinwood Avatar answered Jan 05 '23 00:01

John Ellinwood