How to import a jar file?

I use IntelliJ Idea to write an application, but I don't know how to import a jar file I need, and I compile and run it from console with javac/java using the -classpath option. Is there any way to use the IDE to compile and run my application? Thank you.


Sure, just add the .jar file in Settings | Project Structure, Modules, module name, Dependencies tab using the Add button. You will probably need a Module Library (choose from the drop-down).


I imported that jar but I still get an exception when I try to run it from the IDE, though it works fine if I run it with "java" from the console. Any ideas? Thank you.


Please send your sample project illustrating the issue to


Please sign in to leave a comment.