How can I add an external library to a project in IntelliJ IDEA so that when I build an artifact it still has access to the classes in the library?
I have created a
If you are using maven to build your application then this is not the correct way to add external library. You should either
mvn install:install-file -Dfile=myJar.jar -DgroupId=com.yourproject -DartifactId=yourproject -Dversion={version} -Dpackaging=jar
. Option 1 is prefered since you don't have to keep jar in your project.
You have 2 options here:
Manifest.MF
and copy them near the application main jarI've prepared a sample project that demonstrates both approaches: HelloWithDependencies.zip.
The artifacts are produced into out\single
and out\linked
directories.
Relevant configurations: