如何将现有目录导入 Eclipse?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8611196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to import an existing directory into Eclipse?
提问by Sarmen B.
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:
我使用的是 mac,但我认为这不会有什么不同。我有一个目录,我想将其完全导入/添加到 Eclipse 中。我所做的是这样的:
- Right click import
- 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.
然后,当我单击浏览根目录或存档文件并选择文件夹时,我无法单击完成。该文件夹是空的,只包含几个文件夹,但由于某种原因,我无法单击完成。
回答by Diego
The Eclipse UI is a little bit confusing.
Eclipse UI 有点混乱。
The Import -> "Existing projects into workspace" actually means import "Existing Eclipseprojects 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.
导入 ->“现有项目到工作区”实际上意味着将“现有Eclipse项目导入工作区”。这就是您不能单击完成的原因:导入选项会.project
在您选择的目录中查找文件(Eclipse 用于存储项目选项的文件)。
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):
要导入没有 Eclipse 项目文件的现有源代码,您有以下选项(我假设您想创建一个 Java 项目):
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 systemthen choose your files, and it will make a copyof your files.
Tip:you can drag&drop your files from the Finder into the src folder.
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 locationoption, and choose the directory where is your non-Eclipse project.
- Click Nextand configure the sub-directories of your non-Eclipse project where the source files are located. And you are done :)
工作区目录中的新项目:在工作区中创建一个新的空 Java 项目(File->New->Java Project)。然后右键单击源文件夹并选择导入...->常规->文件系统,然后选择您的文件,它会复制您的文件。
提示:您可以将文件从 Finder 拖放到 src 文件夹中。
在现有目录中创建一个 eclipse 项目:创建一个新的 Java 项目,但在“新建 Java 项目”窗口中:
- 取消选中Use default location选项,然后选择非 Eclipse 项目所在的目录。
- 单击下一步并配置源文件所在的非 Eclipse 项目的子目录。你完成了:)
回答by spiderman
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
无需创建 Java 项目,也无需让不必要的 Java 依赖项和库附着在项目中。问题是关于将现有目录导入 eclipse
Suppose the directory is present in C:/harley/mydir. What you have to do is the following:
假设该目录存在于C:/harley/mydir 中。您需要做的是:
Create a new project (Right click on Project explorer, select New -> Project; from the wizard list, select General -> Projectand click next.)
Give to the project the same name of your target directory (in this case mydir)
Uncheck Use default locationand give the exact location, for example C:/harley/mydir
Click on Finish
创建一个新项目(右键单击项目资源管理器,选择New -> Project;从向导列表中,选择General -> Project并单击下一步。)
为项目提供与目标目录相同的名称(在本例中为mydir)
取消选中使用默认位置并给出确切位置,例如C:/harley/mydir
点击完成
You are done. I do it this way.
你完成了。我这样做。
回答by Matt Gibson
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:
现在,有一个更好的解决方案来导入现有的 PHP 项目。PDT 插件现在在 New PHP Project 对话框中有一个选项。所以:
From File->New->PHP Project:
从文件->新建->PHP项目:
回答by Mostafa
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:
我使用下面的简单方法来创建一个项目 1-首先在一个希望使其成为项目的目录中,创建一个包含以下内容的 .project 文件:
<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
2- 现在代替“项目名称”,写下您的项目名称,也许是当前目录名称
3- Now save this file to directory that desire to make that directory as project with name ".project" ( for save like this, use Notepad )
3-现在将此文件保存到希望将该目录作为名为“.project”的项目的目录(对于这样的保存,请使用记事本)
4- Now go to Eclips and open project and add your files to it.
4- 现在去 Eclips 并打开项目并将您的文件添加到其中。
回答by Ostati
For Spring Tool Suite
I do:
因为Spring Tool Suite
我这样做:
File -> Open projects from File System
回答by LoveMeow
The thing that works best for me when that happens is :
发生这种情况时最适合我的事情是:
Create a new eclipse project(JAVA)
Take your source file (contents of the src folder!!!) and drag from finder and drop into the src folder in eclipse IDE
Make sure you add your external jars and stuff and tada you're done!!
创建一个新的eclipse项目(JAVA)
获取您的源文件(src 文件夹的内容!!!)并从 finder 中拖放到 eclipse IDE 中的 src 文件夹中
确保你添加了你的外部罐子和东西,你就完成了!!