2

With intelliJ IDEA, how do I manually add a .jar to my web-inf/lib folder?

It is a maven project and I have been adding .jar's via pom.xml thus far.

I manually dropped the .jar, but it didn't seem to pick up the .jar since it doesn't pick up the namespace when I add a import statement etc.

Blankman
  • 259,732
  • 324
  • 769
  • 1,199

3 Answers3

2

Add the WEB-INF/lib directory to your project libraries.

Ctrl-Shift-Alt-S, then choose "Libraries" and attach your WEB-INF/lib as a JAR directory. Every JAR in that directory will be added to CLASSPATH for compilation.

Obviously, WEB-INF/lib JARs are automatically in CLASSPATH when you run a WAR file, so you're fine at runtime.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • yes when I built my artifact to deploy, the .jar was in the web-inf/lib (along with the others via pom.xml) – Blankman Jul 15 '10 at 02:15
1

If you use Maven, you don't do that (since Maven wouldn't be aware of it), you add dependencies in the POM and let the IDE derive the project configuration from it. What's the point of using Maven if you can't build your code with it? So either use Maven and add the dependency to the pom.xml or... don't use it.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • so you would suggest adding the .jar to my local repo? – Blankman Jul 15 '10 at 14:33
  • I suggested [several solutions](http://stackoverflow.com/questions/3242924/using-idea-with-maven2-how-to-add-a-non-maven-jar/3247268#3247268) to deal with non Maven JARs, adding them to your local repository being one of them (not the best from a portability point of view). – Pascal Thivent Jul 15 '10 at 19:42
0

In Intellij IDEA right click on WEB-INF/lib directory and choose "Add as Library..." Worked for me. Hope it helps!