Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add tomcat jar/lib directory to eclipse classpath on Mac OS X [duplicate]

I have a project that requires some Tomcat libs to run properly. I installed Tomcat (on Mac) which is essentially just a put-the-folder-somewhere process. I originally resolved the issue by adding the needed jar files as external jars for the project - however this messes with the project .classpath which I can't allow - those changes would be tracked in our source control.

I've tried adding the tomcat/lib directory to eclipse as a classpath variable but that doesn't resolve the issue.

When the tomcat server starts, I receive ClassNotFoundException: HttpServletRequest.

How else can I add the tomcat lib directory so that I'm not modifying the project classpath?

like image 494
helion3 Avatar asked Oct 18 '13 22:10

helion3


1 Answers

You can install Webtools plugin (installed by default in Eclipse for JavaEE Developers) and then you will get Tomcat runtime support. Then you can add a "Tomcat Runtime" to your project and it will automatically include all Tomcat jars that are available to webapps running on Tomcat.

  1. Window > Preferences > Server > Runtime environments
  2. Add..
  3. Select Tomcat version
  4. Browse to tomcat install dir
  5. Right click you project > Properties
  6. Select Java Build Path
  7. Add library... > Server Runtime > select your runtime you created

This process will also modify your .classpath file but it will do so in a way that is easy to share with other developers.

enter image description hereenter image description here

like image 162
gamerson Avatar answered Sep 23 '22 07:09

gamerson