简体   繁体   中英

How do I exclude a package from an imported JAR for a project in Eclipse?

How do I exclude a package from an imported JAR for a project in Eclipse?

I managed to figure out how to exclude a default package from all the projects, but not just one alone from a imported JAR nor for a specific project. I didn't see anything that resembled what I needed from the filters.

  1. Right-click on your java project
  2. Select Build Path->Configure build path, then Libraries tab
  3. locate your referenced JAR, then expand its properties with the little triangular arrow on its left: 在此处输入图片说明
  4. Click on "Access rules", then on the "Edit ..." button on the right
  5. In the "Type Access Rules" window, click "Add ..."
  6. For "Resolution", select "Forbidden"
  7. In the "Rule Pattern" field, type in your exclusion pattern. If you want to exclude the default package classes, and only those (that's how I read your question), then the pattern would simply be: [*]. For a full description of patterns, check out the ANT page which this mechanism is based on.
  8. Click OK on all open windows.

The classes you've excluded should now no longer be available in your project. I tested the steps above on Eclipse Kepler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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