Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

Answered

When creating a new Java project in IntelliJ IDEA, the following directories and files are created:

./projectname.iml
./projectname.ipr
./projectname.iws
./src/

I want to configure IntelliJ IDEA to include my dependency JARs in ./lib/*.jar to the project. What is the correct way to achieve this in IntelliJ IDEA? www.epayitonline.com

 

0
1 comment

You need to define it as a Project Library in Project Structure dialog and then add this library as a dependency to a module.

But the recommended approach is to use Maven or Gradle for managing dependencies. IDE provides corresponding project template for Java Gradle or Maven based projects, so you may use the corresponding project template type for this.

Then, to use the jars from your local ./lib/*.jar folder in Maven, these jars need to be added Maven local repository, see https://stackoverflow.com/a/4955695/2000323

Btw .ipr .iws files are legacy project configuration files format. It is recommended to use new project-based format for configuration files.

0

Please sign in to leave a comment.