简体   繁体   English

项目未出现在Eclipse的资源管理器中

[英]Project not appearing in Eclipse's explorer

I am new to Java programming. 我是Java编程的新手。 Until now, all I was doing was writing the code on eclipse and running the code there only. 到目前为止,我所做的只是在eclipse上编写代码并仅在其中运行代码。 However this time i tried to write a code in text editor and run the same through following: 但是这一次我试图在文本编辑器中编写代码,并通过以下方式运行相同的代码:

  1. I created a folder named TEMP3 in workspace. 我在工作区中创建了一个名为TEMP3的文件夹。 (I could see as well the folders of other projects that I directly created on eclipse.) (我还可以看到我直接在eclipse上创建的其他项目的文件夹。)
  2. Created a hello.java file in text editor which outputs "Hello world" and saved that file in the folder TEMP3 created above. 在文本编辑器中创建了一个hello.java文件,该文件输出“ Hello world”,并将该文件保存在上面创建的文件夹TEMP3
  3. Now I successfully compiled and run the file. 现在,我成功编译并运行了文件。
  4. Now when I open eclipse, I expect to see the TEMP3 Project (and in there the hello class) in eclipse's Package Explorer. 现在,当我打开eclipse时,我希望可以在eclipse的Package Explorer中看到TEMP3项目(以及hello类)。

But I don't see the TEMP3 folder. 但是我看不到TEMP3文件夹。 Why is it so? 为什么会这样呢?

You could try to import your new folder "TEMP3" and then it should appears. 您可以尝试导入新文件夹“ TEMP3”,然后它应该出现。

I'm studying java from middle february 2017 and I can suggest you to use a correct package structure with right names. 我正在从2017年2月中旬开始研究Java,我可以建议您使用具有正确名称的正确软件包结构。 It helps a lot during programming. 在编程过程中有很大帮助。

Eclipse projects must contain at least a .project file for Eclipse to recognize them as a project. Eclipse项目必须至少包含一个.project文件,Eclipse才能将它们识别为项目。 The folder you have created doesn't contain this file so it isn't recognized. 您创建的文件夹不包含此文件,因此无法识别。

In addition to this Eclipse won't recognize a project added to the workspace externally until you do a 'File > Refresh'. 除此之外,除非您执行“文件>刷新”,否则Eclipse不会从外部识别添加到工作区的项目。

So the best bet is to create a Java project inside Eclipse in the normal way and then use 'Import > File System' to import the hello.java file. 因此,最好的选择是以常规方式在Eclipse中创建一个Java项目,然后使用“导入>文件系统”导入hello.java文件。

Note that the Eclipse Package and Project Explorers normally hide the .project file so you don't see it in Eclipse. 请注意,Eclipse包和项目浏览器通常会隐藏.project文件,因此您不会在Eclipse中看到它。 In addition on Linux and macOS the OS doesn't show files starting with '.' 此外,在Linux和macOS上,操作系统不会显示以“。”开头的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM