The Java project actually exists but the import fails

Yesterday, I collapsed the Java project in Eclipse. Then there is a strange phenomenon, that is, there are Java projects in the workspace but cannot be imported, and an error is reported: Cannot import into a workspace with no open projects. Please create a project before...

This problem is divided into several situations, I will list them one by one below.
The first one is missing .project and .classpath in the project, or missing one of the two. The solution is to find the .project file and .classpath file under the directory of another Java project. For example, as shown in the figure below, there is a Java project under my E drive, and there is a problem with the G drive Java project. I went to drive E and copied the two files of that Java project to the directory of the problematic Java project on drive G.
Insert picture description here
Insert picture description here
Then, open the modified .project file in Notepad, and change the content in the name tag to the name of the Java project in question. As shown in the figure below:
Insert picture description here
Second, create a new project in Eclipse with the same name as the project that needs to be imported, and then copy the project code file directly to the new project. In fact, it is equivalent to rebuilding the project. I don't recommend it.

The third, the most effective method I have explored, is to directly rename the problematic Java project to another name. For example, my previous Java project was Java_demo and I renamed it to Java_demon. Then, the same as the first method. Then, open the .project file and rename it. It can be imported successfully! ! However, I solved a problem after the project was imported! That is, the original Java_demo folder still exists, as shown in the figure below:
Insert picture description here
Do not imitate this step. I have been thinking about it for a long time and it is useless. After deleting it,,,, Eclipse cannot be opened because it works Space Workspace path is invalid! The error was reported as shown in the figure below:
Insert picture description here
Then, after referring to the article of the big brother, I was pulled back from the edge of death again. If you accidentally delete the previous Java project folder, the workspace fails and Eclipse cannot be opened. Don't panic, it will regenerate back. Then, we go to find the
Insert picture description here
x.snap file to delete, and then reopen Eclipse.

In order to solve this problem, I also entered a lot of pits at the beginning. After referring to the article of the boss, I thought of a way to modify the project name and solved it. I also owe it to the article of the boss, the article address: Article 1 , Article 2 , Article 3 . I wish everyone a smooth solution to the problem.

Finally, thank you all for coming to watch my article. There may be many improprieties in the article, and I hope to point out He Haihan.

Guess you like

Origin blog.csdn.net/weixin_43408020/article/details/114328975