Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project
Steps for adding external jars in IntelliJ IDEA:
- Click File from the toolbar
- Select Project Structure option (CTRL + SHIFT + ALT + S on Windows/Linux, ⌘ + ; on Mac OS X)
- Select Modules at the left panel
- Select Dependencies tab
- Select + icon
- Select 1 JARs or directories option
How to add external library in IntelliJ IDEA?
Easier procedure on latest versions:
- Copy jar to libs directory in the app (you can create the directory it if not there)
- Refresh project so libs show up in the structure (right click on project top level, refresh/synchronize)
- Expand libs and right click on the jar
- Select "Add as Library"
Done
How to add a Jar file to external library on IntelliJ IDEA
You are trying to add a *-sources.jar
, which is a file that only contains the sources (this is useful if you are debugging, and want to see what the library is doing).
Instead you need to add the jar file with the compiled code. Given the library name you mention, that would usually be called play-java-ebean_2.10.jar
(that is: without -sources
).
IntelliJ add external jar as dependency from relative path
If the library is inside the project root, the path will be stored relatively using the placeholder.
In the library .xml
file or in the project .iml
file you'll see something like this:
<component name="libraryTable">
<library name="log4j-1.2.17">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/log4j-1.2.17.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
How do you add external libraries to intellij project during setup?
In the File>Project Structure (Ctrl+Alt+Shift+S) there is a tab named libraries -> Click on + -> Libraries
Also you can create a project in which the dependencies are managed by Gradle or Maven. Depending on the library you want to import, there use to be a section on the website of each library dedicated to guiding how to import in Maven or Gradle.
How to add external jar library file to Intellij Idea android project
if you are using Gradle I believe you also should modify build.gradle for your module.
In section dependencies add line like this:
compile fileTree(dir: 'libs', include: ['*.jar'])
like in this answer:
https://stackoverflow.com/a/13072692/1570833
Hope this helps!
Cheers
Related Topics
How to Ping External Ip from Java Android
Error: Could Not Find or Load Main Class
How to Execute Bash Command With Sudo Privileges in Java
Growing Resident Memory Usage (Rss) of Java Process
React on Global Hotkey in a Java Program on Windows/Linux/Mac
What Is the Reason Behind "Non-Static Method Cannot Be Referenced from a Static Context"
How to Stop Repeated Keypressed()/Keyreleased() Events in Swing
Running a Jar File Without Directly Calling 'Java'
Limit Jvm Process Memory on Ubuntu
Difference Between Public, Protected, Package-Private and Private in Java
Swing Gui Listeners Without Awt
Add a Complex Image in the Panel, With Buttons Around It in One Customized User Interface