Explain Codes LogoExplain Codes Logo

How do I hide .class files from the Open Resource dialog in Eclipse?

java
eclipse-configuration
resource-filters
working-sets
Nikita BarsukovbyNikita Barsukov·Nov 7, 2024
TLDR

Exclude .class files swiftly in Eclipse:

  1. Use Ctrl + Shift + R to bring up Open Resource.
  2. Click the arrow, top-right, for View Menu.
  3. Select Filters... and tick "*.class".
  4. Click OK to activate.

Your .class files are now camouflaged in search results.

The .class hide-n-seek: Strategies revealed!

While managing the visibility of .class files, we'll uncover key strategies: Using the Derived attribute, the Resource Filters, and Working Sets.

Using 'Derived' as file invisibility cloak

Marking your root or specific output folders as Derived to hide like Harry Potter!

/** Right-click the output folder ('bin' or 'target'). **/ /** Must resist urge to click 'Delete...' */ /** Choose 'Properties'. **/ /** Oh look, Property Brothers aren't here! **/ /** Tick 'Derived' under 'Resource attributes'. **/ /** Yes, 'Derived'. Not 'Deprived'. **/ /** Apply changes. **/ /** Feel the magic work! **/

Eclipse now understands these files aren't primary source files, and voila, they're hidden in your searches.

Resource Filters: Your guardian against clutter

Project-specific Resource Filters sweeps .class files under the rug:

/** Right-click the project and select 'Properties'. **/ /** Sounds like real-estate, right? **/ /** Navigate to 'Resource > Resource Filters'. **/ /** Click 'Add...' to define your filter. **/ /** Like adding solitaire to your lunch break. **/ /** Ensure 'Exclude all' and 'Files' are selected with patterns like "*.class". **/ /** It's like hide and seek for files. **/ /** Tick 'recursive' for directories like 'bin' or 'build'. **/ /** Practise Recursive Occlusion. Fancy words! **/

Tailoring .class visibility with Working Sets

Optimize search speed in large projects, by befriend Working Sets:

/** Window > Show View > Other... > General > Working Sets. **/ /** No, not 'Wrestling Sets'. **/ /** Create a new 'Working Set' with desired filters. **/ /** "You shall not pass!"-Gandalf style. **/ /** Choose resources to include or exclude. **/ /** Like being the boss of your own reality show. **/ /** Save and apply the Working Set. **/ /** 'apply'. Not 'apple'. **/

Categorize and manage resources with Java Main Source and Java Test Source working sets for a more organized living.

Customizing Eclipse: For each project, its own

Tailor-fit Eclipse settings for the divergent needs of different projects.

Optimizing for large projects

For Titanic-sized codebases:

  • 'Resource Filters' for swift navigation.
  • Exclude build directories like 'bin/', 'build/' or 'target/'.
  • Working Sets allows custom searches focused on source and test directories.

Sweeping directory-specific clutter under the rug

When you need to handle directories:

  1. Under 'Resource Filters', select 'Exclude all' and 'Folders'.
  2. Specify pathnames such as 'bin/' or 'target/'.

This helps you focus on the important stuff and navigate more cleanly.

Consistency across workspaces

While a universal .class hiding option for all workspaces isn’t available, your customized settings can be reused in new projects. This way, you enjoy a standardized yet customized IDE experience.