14

I have tried many combinations and every time I try to add the jars from the lib directory, intelliJ puts the path down as the src directory. I don't know why. When I move the jars to the src/ directory, intelliJ then switches the path to the lib/ directory. I am not sure how to get this to work correctly.

Scott
  • 151
  • 1
  • 1
  • 5

2 Answers2

16

I'm using Intellij IDEA 11.1, trying to add the Selenium Standalone Server 2 JAR to my new Java project, which already has a module. I could not add the .jar to the Project settings Module (as suggested in another answer), but I can add it to either the project or global libraries. This appears to be the best place for it in Intellij IDEA 11.1.

To add the JAR to the project library (individual modules):

Ensure that the project to which you want the JAR added is open, then choose: File > Project Structure > Libraries > [+] (New Project Library) > Java > .../selenium-server-standalone-2.24.1.jar > [Select the module to add the JAR to] > OK

To add the JAR to the global library (so it's used for all projects):

File > Project Structure > Global Libraries > [+] New Global Library > Java > .../selenium-server-standalone-2.24.1.jar > OK

My Selenium project now compiles and runs as expected. (-:

Steve HHH
  • 12,947
  • 6
  • 68
  • 71
  • For some reason, out of the blue, this stopped working for added directories. I had a directory under the global libraries, which worked for a while, then suddenly this morning they're no longer being recognized. – Carcigenicate Jun 07 '16 at 19:57
14

Project structure -> Modules -> -> Add... -> Library -> Java -> Attach Jar Directories... (for IDEA 10). Are you doing the same?

Timofei Davydik
  • 7,244
  • 7
  • 33
  • 59
  • yeah, I did that. For some reason, it's not putting the classes in when it creates the WAR. I didn't write any ant build tasks, but since I'm working with google App Engine, I didn't think I needed to, since it builds the application for me. I'm starting to think I need to make an ant task. – Scott Apr 05 '11 at 05:49