How to import an existing directory into Eclipse?

Eclipse

Eclipse Problem Overview


I am on a mac, but I don't think it will make a difference. I have a directory that I want to fully import/add into Eclipse. What I did is this:

  1. Right click import
  2. General → Existing Projects into Workspace

Then when I click browse for either root directory or archive file and select the folder I can't click finish. The folder is empty and just contains a few folders but for some reason I can't click finish.

Eclipse Solutions


Solution 1 - Eclipse

The Eclipse UI is a little bit confusing.

The Import -> "Existing projects into workspace" actually means import "Existing Eclipse projects into workspace". That's why you can't click on finish: the import option looks for a .project file (the file used by Eclipse to store the project options) in the directory that you have chosen.

To import existing source code that doesn't have an Eclipse project file you have the following options (I suppose that you want to create a Java project):

  1. New project inside the workspace dir: Create a new empty Java project into the workspace (File->New->Java Project). Then right click on the source folder and choose Import...->General->File system then choose your files, and it will make a copy of your files.

Tip: you can drag&drop your files from the Finder into the src folder.

  1. Create an eclipse project in your existing dir: Create a new Java project, but in the "New Java Project" window:
  • Un check the Use default location option, and choose the directory where is your non-Eclipse project.
  • Click Next and configure the sub-directories of your non-Eclipse project where the source files are located. And you are done :)

Solution 2 - Eclipse

There is no need to create a Java project and let unnecessary Java dependencies and libraries to cling into the project. The question is regarding importing an existing directory into eclipse

Suppose the directory is present in C:/harley/mydir. What you have to do is the following:

  • Create a new project (Right click on Project explorer, select New -> Project; from the wizard list, select General -> Project and click next.)

  • Give to the project the same name of your target directory (in this case mydir)

  • Uncheck Use default location and give the exact location, for example C:/harley/mydir

  • Click on Finish

You are done. I do it this way.

Solution 3 - Eclipse

These days, there's a better solution for importing an existing PHP project. The PDT plugin now has an option on the New PHP Project dialog just for this. So:

From File->New->PHP Project:

New PHP Project Dialog with

Solution 4 - Eclipse

I Using below simple way to create a project 1- First in a directory that desire to make it project, create a .project file with below contents:

<projectDescription>
	<name>Project-Name</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
	</buildSpec>
	<natures>
	</natures>
</projectDescription>

2- Now instead of "Project-Name", write your project name, maybe current directory name

3- Now save this file to directory that desire to make that directory as project with name ".project" ( for save like this, use Notepad )

4- Now go to Eclips and open project and add your files to it.

Solution 5 - Eclipse

For Spring Tool Suite I do:

File -> Open projects from File System

Solution 6 - Eclipse

The thing that works best for me when that happens is :

  1. Create a new eclipse project(JAVA)

  2. Take your source file (contents of the src folder!!!) and drag from finder and drop into the src folder in eclipse IDE

  3. Make sure you add your external jars and stuff and tada you're done!!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionExploitView Question on Stackoverflow
Solution 1 - EclipseDiegoView Answer on Stackoverflow
Solution 2 - EclipsespidermanView Answer on Stackoverflow
Solution 3 - EclipseMatt GibsonView Answer on Stackoverflow
Solution 4 - EclipseMostafaView Answer on Stackoverflow
Solution 5 - EclipseOstatiView Answer on Stackoverflow
Solution 6 - EclipseLoveMeowView Answer on Stackoverflow