如何将缺少 .project .settings .classpath 文件的 java 项目导入 eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14769451/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:57:58  来源:igfitidea点击:

How to import a java project missing .project .settings .classpath files into eclipse

javaeclipse

提问by SachinJ

I got a java source code from an opensource project. The source code doesn't have eclipse project specific files such as .project ,.classpath ,.setting(directory). How can I import that java source into eclipse ?

我从一个开源项目中得到了一个 java 源代码。源代码没有 Eclipse 项目特定的文件,例如 .project 、.classpath 、.setting(directory)。我怎样才能将该 java 源导入到 eclipse 中?



I don't have pom.xml(mvn) file to specify. So I tried manually.

我没有要指定的 pom.xml(mvn) 文件。所以我手动尝试。

followed the below steps to solve

按照以下步骤解决

  1. Create a directory with the projectName and a directory "src" under projectName.
  2. Move the source code ( ie: org/apache/hadoop directory) into src directory under projectName.
  3. Create a sample project in eclipse and go the workspace and modify the .project xml file by changing the project name ,.settings ,.classpath files
  4. Copy the modified ".project" file and ".settings" ,".classpath" from eclipse workspace project directory to the newly created directory "projectName/" 5 .Use eclipse import option under File menu to import the newly created project use Existing project into workspace option
  5. Give the project root directory as projectName directory.
  1. 使用 projectName 创建一个目录,在 projectName 下创建一个目录“src”。
  2. 将源代码(即:org/apache/hadoop 目录)移动到projectName 下的src 目录中。
  3. 在eclipse中创建一个示例项目并进入工作区并通过更改项目名称、.settings、.classpath文件来修改.project xml文件
  4. 将修改后的“.project”文件和“.settings”、“.classpath”从eclipse工作区项目目录复制到新创建的目录“projectName/” 5.使用文件菜单下的eclipse导入选项导入新创建的项目使用现有项目进入工作区选项
  5. 将项目根目录指定为 projectName 目录。

回答by TheWhiteRabbit

if you are using maven type mvn eclipse:eclipseon project folder

如果您mvn eclipse:eclipse在项目文件夹上使用 maven 类型

if you are not using maven, go to eclipse, import->import -> general -> filesystem (then select your directory with source files)

如果您不使用 maven,请转到 eclipse,导入->导入-> 常规-> 文件系统(然后选择包含源文件的目录)

回答by Edward Wu

If you doesn't have .project .classpath and .settings file, Representing the project isn't eclipse project, so you should create a standard eclipse project

如果你没有 .project .classpath 和 .settings 文件,代表项目不是eclipse项目,所以你应该创建一个标准的eclipse项目

you can following below step:

您可以按照以下步骤操作:

  1. copy your project or open source project into workspace.
  2. window ->File ->New -> Java Project ->Project name input that just be copied project file name ->Finish
  1. 将您的项目或开源项目复制到工作区。
  2. window ->File ->New -> Java Project ->Project name 输入刚才复制的项目文件名 ->Finish

Remember config your source code location:

记住配置你的源代码位置:

project ->Properties ->Java Build Path ->Source

项目 -> 属性 -> Java 构建路径 -> 源代码

回答by Avinav Mishra

If this is a maven project then you will not find these .project files. So instead of using import -> Existing project to Workspace use Existing Maven Project.

如果这是一个 Maven 项目,那么您将找不到这些 .project 文件。因此,不要使用 import -> Existing project to Workspace 使用 Existing Maven Project。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明