Home > Software engineering >  How can Eclipse find the jar in the editor but not when it's time to compile?
How can Eclipse find the jar in the editor but not when it's time to compile?

Time:07-21

I am trying to build a dynamic web project - if I add the Tomcat as a dependency, it does compile just fine. However, I have run into a peculiar situation that doesn't resolve properly.

Obviously I have many references to servlet-api.jar in my code for things like HttpServlet. Eclipse complains that it can't find HttpServlet and yet when I ctrl click HttpServlet it recognizes that it lives in c:\programs\tomcat\lib\servlet-api.jar - how can it know that it's there during editing and yet not during build/compile/export?

CodePudding user response:

Ctrl Click works by different rules. Because of the way the type indexing works, it doesn't attempt to fully qualify the type you're hovering over if the reference is not already fully qualified, so it will still match types of the same name in different packages. It's faster, and usually doesn't cause confusion.

  • Related