106

I am trying to "import existing project into workspace". As the "root directory" I select the directory where all my .java (and .class) files are located. Eclipse writes me that "no projects are found to import". Why?

Roman
  • 124,451
  • 167
  • 349
  • 456

11 Answers11

193

This answer is same as Laura's answer , however, in new eclipse versions you will not be able to see a "create project from existing source" option.

Hence you can do this instead:

  • Goto File > New > Project

  • Select the type of project, click Next

  • Uncheck Use default location

  • Click on Browse to navigate to your source folder, or type in the path to your source

  • Click Finish

Taken from this discussion forum in eclipse.org

Snigdha Batra
  • 867
  • 8
  • 16
Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152
  • 48
    +1. I spend my 20 minutes in finding 'create project from existing source' option. – Ajinkya Dec 07 '11 at 05:55
  • 2
    In a newer version of Android... From the menu just select: File->New->Project (not Android Project nor Java Project). Then under Wizards select: Android->Android Project from Existing Code – paiego Sep 25 '12 at 19:51
  • If you don't have Android Project as an option like @paiego suggested, you can also use New JavaScript Project. – Snekse Apr 24 '14 at 22:52
  • Doesn't work for me. It shows ' overlaps the location of another project : '. Using Eclipse luna (4.4.0). – Shubham A. Jun 15 '16 at 10:19
  • see this http://stackoverflow.com/questions/11733089/eclipse-error-overlaps-the-location-of-another-project-when-trying-to-cr – Saher Ahwal Jun 15 '16 at 18:52
  • It does not work for me (eclipse 2020-6) because if i uncheck "Use default location" the Finish button also gets greyed out so it cant be created. – Coliban Aug 04 '20 at 10:40
115

Eclipse is looking for eclipse projects, meaning its is searching for eclipse-specific files in the root directory, namely .project and .classpath. You either gave Eclipse the wrong directory (if you are importing a eclipse project) or you actually want to create a new project from existing source(new->java project->create project from existing source).

I think you probably want the second one, because Eclipse projects usually have separate source & build directories. If your sources and .class files are in the same directory, you probably didn't have a eclipse project.

laura
  • 7,280
  • 4
  • 35
  • 43
  • 1
    I think you are right. I have removed ".project" and ".classpath" files from the directory and then I got the described problem. But I just tried to "create project from existing source". It seems to work. But I still do not have the ".project" and ".classpath" files into the directory. So, eclipse created a project but it did not create files associated with the project. Do you know why? – Roman Apr 14 '10 at 14:18
  • 1
    Check your workspace folder. I believe there should be a folder with the name of your project and the two files in it. One of them probably has the path to where your real classes are. – laura Apr 14 '10 at 17:20
  • 8
    there is no such thing as create project from existing source....I cannot see it.......when you press new -> java project .........then there are no more options, you just get the dialog for adding a new project. – Saher Ahwal Jul 12 '11 at 18:35
  • 11
    Correction: this "create project from existing source" option doesn't exit in new eclipse versions. See my answer below in case you have the new eclipse. – Saher Ahwal Jul 18 '12 at 16:31
23

One solution to this is to use Maven. From the project root folder do mvn eclipse:clean followed by mvn eclipse:eclipse. This will generate the .project and .classpath files required by eclipse.

PaulF
  • 231
  • 2
  • 3
13

In new updated eclipse the option "create project from existing source" is found here, File>New>Project>Android>Android Project from Existing Code. Then browse to root directory.

enter image description here

Priyantha
  • 4,839
  • 6
  • 26
  • 46
Monica M
  • 161
  • 3
  • 12
12

I have a perfect solution for this problem. After doing following simple steps you will be able to Import your source codes in Eclipse!


First of all, the reason why you can not Import your project into Eclipse workstation is that you do not have .project and .classpath file.

Now we know why this happens, so all we need to do is to create .project and .classpath file inside the project file. Here is how you do it:


First create .classpath file:

  1. create a new txt file and name it as .classpath
  2. copy paste following codes and save it:

    <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath>



Then create .project file:

  1. create a new txt file and name it as .project
  2. copy paste following codes:

    <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>HereIsTheProjectName</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription>

  3. you have to change the name field to your project name. you can do this in line 3 by changing HereIsTheProjectName to your own project name. then save it.


That is all, Enjoy!!

Mai
  • 301
  • 3
  • 5
  • 2
    I found copying the files from another project files, and just changing the name. – hram908 Oct 06 '18 at 23:53
  • Exactly. If the project which you wants to import doesn't have .project and .classpath files then eclipse/sts will not identify your project to import – Sumanth Varada Jul 08 '19 at 06:41
4

Reason : your ID is not able to find the .project file. This happens in git commit where many time people don't push .project file

Solution : If you have maven install then use following stapes

  1. mvn eclipse:clean
  2. mvn eclipse:eclipse

Enjoy!

Gauranga
  • 931
  • 1
  • 9
  • 17
3

After a long time finally i found that! Here my Way: File -> New Project -> Android Project From Existing Code -> Browse to your project root directory finish!

Hadi hashemi
  • 475
  • 6
  • 8
1

If you don't have I just have .project and .classpath files in the directory, the only way that works (for me at least) with the latest version of Eclipse is:

  1. Create a new Android project
    • File -> New -> Project... -> Android -> Android Application Project -> Next >
    • Fill in the values on this page and the following according to your application's needs
  2. Get your existing code into the project you just created
    • Right click the src file in the Package Explorer
    • General -> File System -> Next >
    • Browse to your project, select the necessary files, hit Finish

After this, you should have a project with all your existing code as well as new .project and .classpath files.

Patrick
  • 11,552
  • 7
  • 29
  • 41
0

I had the same issue when I've modified .project xml-file. When I reverted files to original version the project was created, then I was able to import project. Maybe it helps someone who has the same kind of problem ;)

Piotr Czyż
  • 2,702
  • 2
  • 21
  • 15
0

if you are building a maven project through a command console, make sure the following is at the end of the command:

eclipse:eclipse -Dwtpversion=2.0
ChrisThompson
  • 1,998
  • 12
  • 17
0

In order to resolve this problem for android projects. follow the below mentioned steps new->android project->create project from existing source and in this you can give your code location. Now, it will import all the specified project code and will work fine

Vsw10
  • 143
  • 3
  • 10