tags:

views:

28

answers:

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.

+1  A: 

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
yes when I built my artifact to deploy, the .jar was in the web-inf/lib (along with the others via pom.xml)
Blankman
+1  A: 

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
so you would suggest adding the .jar to my local repo?
Blankman
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