0

I have imported a Java Project. It contains various folders and each folder has its own output folder for class files. So I am unable to figure out that how to add these output folders to the build path. If I am not adding these to the build path, eclipse is unable to get the class files. And if I am adding these as Class Folder, I am getting the error :

Source folder cannot output to Library  

Project is a maven project.
Can someone help me in figuring out the issue.

neel
  • 8,399
  • 7
  • 36
  • 50

1 Answers1

1

Not a 100%-sure if i got you correctly:

"its own output folder for class files"

Are those folders all named target? (In that case everything is allright).

"I have imported a Java project" feat. "Project is a maven project"

Try importing it as a Maven Project File -> Import -> Maven -> Existing Maven Projects then browse to the root folder of the Maven project that contains the pom.xml. Eclipse will then be able to handle the rest (like setting the correct folders as source/test folders, building the buildpath etc. )

JBA
  • 2,769
  • 5
  • 24
  • 40
  • Yes, these are target folders – neel Mar 06 '15 at 11:15
  • Alright so faar so good, this looks like that project is a standard Maven project then - If you import it as a Maven Project to eclipse - eclipse will know (based on the defined Maven structures) that the sources are placed under `/main/java/src` and compilation output from the Maven build will be placed under `/target/classes` (both one times per Maven Module/ Project). Eclipse will include the classes under `/target/classes` of each Module/ Project to your buildpath. – JBA Mar 06 '15 at 11:18
  • Note that if you just "need" the other Project (say JUnit) rather than having a need to change/ rebuild it you would just have a dependency to that other project from within your own Maven project to get the required `.jar`s rather than all of the projects sources. – JBA Mar 06 '15 at 11:20
  • I have converted it to maven project using "convert to maven project option". So it is already imported, then how to resolve it. – neel Mar 06 '15 at 11:20
  • @neel lets quickly make sure i understand you correctly: I assume you have one or more Maven project(s) somewhere on your disc (each having a subfolder `/target` somewhere inside it) which you want to be able to use - is that correct? In that case you would just need to Import the existing Maven project - without any conversions. – JBA Mar 06 '15 at 11:23
  • (I dont know about the possibility to convert to a Maven Project but I assume this is only possible if Eclipse does not recognize something as Maven project - most oftenly because it is none :)) – JBA Mar 06 '15 at 11:24
  • or asked simpler: Where did you get the Project you imported? :) (If it is available for me feel free to post a link so i can explain a bit better what you have there and if you realy want to import it as a Maven project into eclipse or rather have your own Maven project with a dependency to that projects build output :)) – JBA Mar 06 '15 at 11:26
  • If I am importing again, it is giving me the error that project is already imported. And yes you are correct that I have one or more maven projects in the same project. – neel Mar 06 '15 at 11:27
  • 1
    It is difficult for me to share the link. – neel Mar 06 '15 at 11:29
  • Unfortunately i cannot start a chat from within the company but to not loose any source i recomend to quickly start a new Eclipse instance and create a new workspace - then import the project again (once imported to eclipse you would need to delete it ... afaik its possible to delete it without deleting anything non-eclipse on the disk but i dont want to guarantee it :)) – JBA Mar 06 '15 at 11:30
  • then dont share it it should still be possible :) – JBA Mar 06 '15 at 11:32
  • I however recomend to quickly read about Maven itself if you dont know much about it as well as Eclipse and Maven since for eclipse there is this plugin i dont know about http://stackoverflow.com/questions/2061094/importing-maven-project-into-eclipse (it however works for any maven project i ever had to import as maven project - then build and run it unless it was misconfigured o.ä.) – JBA Mar 06 '15 at 11:33