Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.project and .classpath files are missing in eclipse

Tags:

eclipse

I have a project where there are a no of applications built as separate Java projects.
These have been sent over by someone and somehow the .project and the .classpath files have not been copied.

So when I try to import it into eclipse it gives me an error:"No project found".
Is there any way to generate the missing files?

like image 346
swati Avatar asked Jun 07 '11 05:06

swati


4 Answers

Let Eclipse Create the Files

Eclipse will make these files for you, but the way to make it do so is not very intuitive.

  1. In Eclipse, make sure the project is not currently showing up in the Project Explorer or Package Explorer. If it is, right-click it and click the Delete button - and make sure the "Delete from Disk" option is unchecked before you hit "Ok"!!!

  2. Select File / New / Java Project

  3. Uncheck Use Default Location, then Click "Browse" and find the folder it is located in.

  4. Click "Next" for more options, or just "Finish".

Eclipse will import the project and automatically create the default .project and .classpath files for you. With the one case I tried, with source in the default src/main/java folder, I could build and run fine at this point.

like image 169
LightCC Avatar answered Nov 08 '22 18:11

LightCC


I've better solution for this issue, only for MAVEN users. To resolve it follow below steps.

  1. GO inside your project D:\workspace\project\. 2.Open command Line prompt and run this command : mvn eclipse:eclipse

Definitely, Your issue will gone.

like image 33
vkstream Avatar answered Nov 14 '22 10:11

vkstream


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 that you 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 .classpath.

  2. Copy and paste following code 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 .project

  2. Copy paste following code:

     <?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 and then saving it.

like image 8
Mai Avatar answered Nov 14 '22 09:11

Mai


You cannot import them as project if .project and .classpath are missing. You can create a new Java project and copy the source files into it.

like image 6
Prakash G. R. Avatar answered Nov 14 '22 08:11

Prakash G. R.