Reputation: 3206
I need to add jstl-1.2.jar to my Dynamic Web Project in Eclipse (Eclipse for Java EE, 4.9.0 version) to enable JSTL support for Tomcat.
I need to add this file into /WebContent/WEB-INF/lib
folder of my project:
But when I right-click that "lib" folder and choose import
from context menu, importing does not work. Import->General->File System
does not see jar files (they are inaccessible for import), Import->General->Archive File
sees jar files, but imports a jar file as a lot of .class files which is not what needed. All other import options are inappropriate.
I found a workaround - I can successfully do it bypassing Eclipse: add my jar file into /WebContent/WEB-INF/lib
simply using Windows Explorer outside of Eclispe and then refresh project from Eclipse. The jar turns out to be on the build path.
But normally when working with any IDE doing stuff not with IDE built-in tools is conceptually wrong. What is the correct way to achieve what I am doing with my workaround?
P.S. I realize that this is why the added jar file turns on to be on the build-path: Web App Libraries
was added to the Libraries tab by default (I didn't even have to press "Add Library" button)
Upvotes: 1
Views: 2069
Reputation: 8587
After you add your libraries to the Java Build Path check also the Deployment Assembly
tab and verify that your deployment setup is correct, that all needed application libraries are added to /WEB-INF/lib (you dont need to go to explorer and add them manually!)
for example:
This means, all under src (source) will end up in the web-inf/classes (compiled!), and all under WebContent will be in your root (html,jsp, images, etc as the path layout you have organized!). And finally that your libraries will be in web-inf/lib. This way you can also do an export of the WAR / EAR and verify the bundle setup!
Upvotes: 1