[英]eclipse doesn't see class file
I have eclipse project. 我有eclipse项目。
I add directory src/directory
and put there SomeClass.java 我添加目录src/directory
并将SomeClass.java放在那里
I compile my application. 我编译我的应用程序。
in somedirectory
in filesystem I see .class
file. 在文件系统的somedirectory
中我看到.class
文件。
But in eclipse somedirectory
looks empty. 但是在Eclipse中, somedirectory
看起来是空的。
What the reason? 是什么原因? How to fix it? 怎么解决?
I press F5 many times! 我多次按F5!
eclipse hides class files when you are in the package explorer. 当您在包资源管理器中时,eclipse会隐藏类文件。 Try to switch to the navigator (Ctrl+3 and type "navigator") then a "bin" folder should appear and that one contains your class file. 尝试切换到导航器(Ctrl + 3并键入“navigator”),然后出现一个“bin”文件夹,其中一个包含您的类文件。
First, the Eclipse src
folder and output folder that will contain the compiled classes are two different folders. 首先,将包含已编译类的Eclipse src
文件夹和输出文件夹是两个不同的文件夹。 These two folders' location are configured in the Project's properties page, under the Java Build Path tab. 这两个文件夹的位置在项目的属性页面中的Java Build Path选项卡下配置。 More information on the configuration can be found here . 有关配置的更多信息,请参见此处 。
So when you press in F5 in Eclipse to refresh the folder, you are basically refreshing the source folder, and you will never see the .class
file in there. 因此,当您在Eclipse中按F5键刷新文件夹时,基本上就是在刷新源文件夹,而您将永远不会在其中看到.class
文件。 The output folder that contains the .class
files are hidden by the Project Explorer view. 包含.class
文件的输出文件夹被Project Explorer视图隐藏。
If you absolutely want to see these files via Eclipse, switch to the Resource perspective and follow the instructions as given by the answer of this SO entry or rather follow instructions given by @markusw , CTRL-3 + Navigator view is way quicker! 如果您绝对想通过Eclipse查看这些文件,请切换到Resource透视图并按照此SO条目的答案给出的说明,或者按照@markusw给出的说明进行操作,CTRL-3 + Navigator视图更快!
The hierarchy of the source directory src
, should be the same as the package name of the classes inside it. 源目录src
的层次结构应该与其中的类的包名称相同。 In other words, if you have a class whose package name is com.example.util
, then that class should be located inside the directory src/com/example/util
. 换句话说,如果你有一个包名为com.example.util
类,那么该类应该位于目录src/com/example/util
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.