Java 如何在 Eclipse 的“打开资源”对话框中隐藏 .class 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2632419/
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
How do I hide .class files from the Open Resource dialog in Eclipse?
提问by bergyman
I won't want to have edit any working sets. I just want a way to, across all workspaces and projects, prevent .class files from ever showing in the Open Resource Dialog. Is there a way to do this?
我不想编辑任何工作集。我只是想要一种在所有工作区和项目中阻止 .class 文件显示在打开资源对话框中的方法。有没有办法做到这一点?
采纳答案by Kevin K
One option is to filter derived resources. In the upper right corner of the 'Open Resource' dialog there is an arrow you can click to bring up a dropdown menu for filtering. Uncheck the 'Show Derived Resources' option, if it is checked.
一种选择是过滤派生资源。在“打开资源”对话框的右上角有一个箭头,您可以单击以显示用于过滤的下拉菜单。如果选中,取消选中“显示派生资源”选项。
If you still see '.class' files, they probably aren't being marked as derived. If they're by themselves in their own folder hierarchy you can fix this by right-clicking the root folder to edit folder properties, and check the 'Derived' checkbox. If they're mixed with your '.java' files...tough luck, you'll need to set the derived property on each '.class' file by hand.
如果您仍然看到“.class”文件,它们可能没有被标记为派生的。如果它们自己位于自己的文件夹层次结构中,您可以通过右键单击根文件夹来编辑文件夹属性并选中“派生”复选框来解决此问题。如果它们与您的“.java”文件混合在一起……运气不好,您需要手动设置每个“.class”文件的派生属性。
As far as I can tell there's no way to mark class files as derived resources globally for the workspace, but I believe when you create a new Java project the 'bin' folder is marked as derived by default (if you use the default wizard settings)
据我所知,无法将类文件全局标记为工作区的派生资源,但我相信当您创建新的 Java 项目时,“bin”文件夹默认标记为派生的(如果您使用默认向导设置)
Here are some screenshots from Eclipse Kepler. The first shows how to filter derived resources by unchecking 'Show Derived Resources' in the Open Resource dialog. The second shows how to set the 'Derived' property on a resource.
以下是来自 Eclipse Kepler 的一些屏幕截图。第一个显示如何通过取消选中“打开资源”对话框中的“显示派生资源”来过滤派生资源。第二个显示了如何在资源上设置“派生”属性。
回答by ring bearer
Version 3.5 Open Resource dialog has a way turn "Show Derived Resources" on/off by a small dropdown menu at the top right hand corner. Turning it off will hide classes.
版本 3.5 打开资源对话框可以通过右上角的小下拉菜单打开/关闭“显示派生资源”。关闭它会隐藏类。
Or
或者
you could type an expression on the "Select an item to open" text box such as : *.java
您可以在“选择要打开的项目”文本框中键入表达式,例如:*.java
回答by puudeli
You can use Working sets
. From the same dropdown menuon Open Resource dialog select Select working set
. It opens up the working set dialogue where you can create working sets if you don't already have them.
您可以使用Working sets
. 从打开资源对话框的相同下拉菜单中选择Select working set
。它会打开工作集对话框,如果您还没有工作集,您可以在其中创建工作集。
When creating a new one, choose the type Resources
and select which folders in your workspace are consider as candidates for searching or for opening resources. I have included only src
and test
folders and usually pom.xml
's and other misc configuration files.
创建新Resources
文件夹时,请选择类型并选择工作区中的哪些文件夹可作为搜索或打开资源的候选文件夹。我只包括src
和test
文件夹,通常包括pom.xml
's 和其他 misc 配置文件。
With the couple of large projects I'm working on it has a noticeable impact on search speed too.
对于我正在处理的几个大型项目,它也对搜索速度产生了显着影响。
回答by Eduardo Cuomo
To change this behaviour and hide the “.class” files you need to do the following.
要更改此行为并隐藏“.class”文件,您需要执行以下操作。
Find your class output folder in the “Project explorer” window. This is usually called binor targetfor Maven projects
Right-click this folder and click Properties
Tick the Derivedcheckbox (leave it UNCHECKED) and click OK
在“项目资源管理器”窗口中找到您的类输出文件夹。这通常称为Maven 项目的bin或目标
右键单击此文件夹,然后单击 Properties
勾选衍生复选框(不要选择它),然后单击OK
.classfiles will now be hidden in future.
.class文件现在将在将来隐藏。
Source: http://ayubmalik.co.uk/2011/12/hide-class-files-when-opening-a-type-or-resource-in-eclipse-ide/
来源:http: //ayubmalik.co.uk/2011/12/hide-class-files-when-opening-a-type-or-resource-in-eclipse-ide/
回答by Rajesh
- Right click on the project and select Properties
- Expand Resourceand click on Resource Filters
- Click on Add Filter...to create a new filter
- On the dialog box that opens
- Select the Exclude alland Filesradio buttons
- Under File and Folder Attributesenter
*.class
- Click OK
- 右键单击项目并选择 Properties
- 展开资源并单击Resource Filters
- 单击Add Filter...以创建新过滤器
- 在打开的对话框中
- 选择Exclude all和 Files单选按钮
- 在文件和文件夹属性下输入
*.class
- 点击 OK
To exclude an entire directory hierarchy, e.g. the target
directory, select the Files and foldersradio button and the All children (recursive)checkbox.
要排除整个目录层次结构,例如target
目录,请选择Files and folders单选按钮和All children (recursive)复选框。
Edit
编辑
Exclude the following for a complete cleanup of Open Resource
dialog
排除以下内容以完全清理Open Resource
对话框
- Files *.class
- Folder bin
- Folder build
- Folder target
- 文件 *.class
- 文件夹
- 文件夹构建
- 文件夹目标
Without excluding all 4 it does not work.
如果不排除所有 4 个,它就不起作用。
回答by Ilyas Soomro
Some time you are not able mark build or bin folder as Derived resource, because eclipse package explorer or project explorer does not show you build or bin folder in project view.
有时您无法将 build 或 bin 文件夹标记为派生资源,因为 eclipse 包资源管理器或项目资源管理器不会在项目视图中显示您的 build 或 bin 文件夹。
What you need to do, to show build folder in project view:
你需要做什么,在项目视图中显示构建文件夹:
Go to
Project > Properties > Java Build Path > Source >
change default output folder to build1 Note: It will ask you to remove old folder and its content, Press No (to restore it later)Now build folder is visible on package explorer, go to folder properties and mark it as Derived
- Now change your default output folder back to build (to restore old setting)
转到将
Project > Properties > Java Build Path > Source >
默认输出文件夹更改为 build1 注意:它会要求您删除旧文件夹及其内容,按否(稍后恢复)现在构建文件夹在包资源管理器上可见,转到文件夹属性并将其标记为派生
- 现在将您的默认输出文件夹更改回构建(以恢复旧设置)
回答by Nadav Finish
Eclipse Luna - just go to the following link
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-48b.htm
OR
1. Create a working set (include all projects)
2. On "Package Explorer" panel click on "Filters" (in the same menu you just created the working set) and deselect "Inner class files" + click ok
Eclipse Luna - 只需转到以下链接
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-48b.htm
或
1. 创建一个工作集(包括所有项目)
2. 在“包资源管理器”面板上单击“过滤器”(在您刚刚创建工作集的同一菜单中)并取消选择“内部类文件”+单击确定
That worked for me
那对我有用
回答by Sameer Kazi
Showing or hiding files in the Project Explorer view You can choose to hide system files or generated class files in one of the navigation views. (System files are those that have only a file extension but no file name, for example .classpath.)
在 Project Explorer 视图中显示或隐藏文件 您可以选择在导航视图之一中隐藏系统文件或生成的类文件。(系统文件是那些只有文件扩展名而没有文件名的文件,例如 .classpath。)
On the toolbar for the Project Explorer, click the Menu button Menu button to open the drop-down menu of display options. Select Customize View..,.
In the dialog box that opens, select the Filters tab and then select the checkboxes for the types of files that you want to hide. In addition, you can restrict the displayed files to a working set.
在 Project Explorer 的工具栏上,单击 Menu 按钮 Menu 按钮以打开显示选项的下拉菜单。选择自定义视图...,。
在打开的对话框中,选择过滤器选项卡,然后选择要隐藏的文件类型的复选框。此外,您可以将显示的文件限制为工作集。
On the toolbar for the Project Explorer, click the Menu button Menu button to open the drop-down menu of display options.
Choose Select Working Set...
Select an existing working set from the list or create a new one by selecting NEw
check here
在 Project Explorer 的工具栏上,单击 Menu 按钮 Menu 按钮以打开显示选项的下拉菜单。选择 Select Working Set... 从列表中选择一个现有的工作集或通过选择 NEw check here来创建一个新的工作集