eclipse 中缺少 .project 和 .classpath 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6260808/
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
.project and .classpath files are missing in eclipse
提问by swati
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.
我有一个项目,其中没有作为单独的 Java 项目构建的应用程序。
这些已被某人发送过来,.project
并且.classpath
文件没有被复制。
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?
因此,当我尝试将其导入 eclipse 时,它给了我一个错误:“ No project found
”。
有没有办法生成丢失的文件?
回答by Mai
I have a perfect solution for this problem. After doing following simple steps you will be able to Import your source codes in Eclipse!
对于这个问题,我有一个完美的解决方案。完成以下简单步骤后,您将能够在 Eclipse 中导入源代码!
First of all, the reasonwhy you can not Import your project into Eclipse workstation is that you do not have .projectand .classpathfile.
首先,该理由为什么你不能导入项目到Eclipse工作站是你没有的.project和的.classpath文件。
Now we know why this happens, so all we need to do is to create .projectand .classpathfile inside the project file. Here is how you do it:
现在我们知道为什么会发生这种情况,所以我们需要做的就是在项目文件中创建.project和.classpath文件。这是你如何做到的:
First create .classpathfile:
首先创建.classpath文件:
- create a new txt file and name it as .classpath
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>
- 创建一个新的 txt 文件并将其命名为 .classpath
复制粘贴以下代码并保存:
<?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 .projectfile:
然后创建 .project文件:
- create a new txt file and name it as .project
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>
you have to change the name field to your project name. you can do this in line 3 by changing HereIsTheProjectNameto your own project name. then save it.
- 创建一个新的 txt 文件并将其命名为 .project
复制粘贴以下代码:
<?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 行中通过将HereIsTheProjectName更改为您自己的项目名称来执行此操作。然后保存它。
That is all, Enjoy!!
就是这样,享受!!
回答by Prakash G. R.
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.
如果 .project 和 .classpath 丢失,则不能将它们作为项目导入。您可以创建一个新的 Java 项目并将源文件复制到其中。
回答by vkstream
I've better solution for this issue, only for MAVENusers. To resolve it follow below steps.
对于这个问题,我有更好的解决方案,仅适用于MAVEN用户。要解决它,请按照以下步骤操作。
- GO inside your project
D:\workspace\project\
. 2.Open command Line prompt and run this command : mvn eclipse:eclipse
- 进入你的项目
D:\workspace\project\
。2.打开命令行提示符并运行此命令:mvn eclipse:eclipse
Definitely, Your issue will gone.
当然,你的问题会消失。
回答by LightCC
The Simplest Solution - Let Eclipse Create the Files
最简单的解决方案 - 让 Eclipse 创建文件
Eclipse will make these files for you, but the way to make it do so is not very intuitive.
Eclipse 会为您制作这些文件,但制作方法不是很直观。
In Eclipse, make sure the project is not currently is not showing up in the Project Exploreror Package Explorer. If it is, right-click it and click the Deletebutton - and make sure the "Delete from Disk" option is unchecked before you hit "Ok"!!!
Select File / New / Java Project
Uncheck Use Default Location, then Click "Browse" and find the folder it is located in.
Click "Next" for more options, or just "Finish".
在 Eclipse 中,确保项目当前未显示在Project Explorer或Package Explorer 中。如果是,请右键单击它并单击“删除”按钮 -并确保在点击“确定”之前取消选中“从磁盘删除”选项!!!
选择文件/新建/Java 项目
取消选中Use Default Location,然后单击“Browse”并找到它所在的文件夹。
单击“下一步”以获取更多选项,或单击“完成”。
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.
Eclipse 将导入项目并自动为您创建默认值.project
和.classpath
文件。在我尝试过的一个案例中,源代码位于默认的 src/main/java 文件夹中,此时我可以正常构建和运行。
回答by vkstream
You don't have need to do anything. Just copy these two files from another projects and paste into that project directory where you getting issue.
你不需要做任何事情。只需从另一个项目复制这两个文件并粘贴到您遇到问题的项目目录中即可。
回答by VonC
See the Java Build Path help page:
请参阅Java 构建路径帮助页面:
- either you create project in the parent directories of the sources (in which case you add an existing subdirectory as your sources)
- or you create an empty project in your Eclipse workspace, and use the "link" feature
- 要么在源的父目录中创建项目(在这种情况下,您将现有子目录添加为源)
- 或者您在 Eclipse 工作区中创建一个空项目,并使用“链接”功能
Creates a new folder that links to an location outside of the workspace
创建一个链接到工作区外部位置的新文件夹
That being said, you will still have to re-create the correct classpath yourself.
话虽如此,您仍然需要自己重新创建正确的类路径。