Axel
Axel

Reputation: 185

How to import library in IntelliJ

I want to use this library in a Java project. How can i import this library and use it in my project?

I've heard about .jar files, that I should add. But this library has no .jar in it, only source files. So I don't know what is the best/cleanest way to import and use this library.

If you need any more information to help, do not hesitate to ask.

Upvotes: 1

Views: 4644

Answers (3)

user11955823
user11955823

Reputation:

There are two ways you can do it

  1. if you have a maven project. Add the below dependency in it. https://github.com/ronmamo/reflections

  2. download the jar file then follow these steps.

    Go to Project

    Open Module Setting

    Select the module

    Click on the (+) sign in the right side --> You will get the options to add as a jar, module dependency or library

You can select whichever way is suitable for you.

here are images for your ease.

enter image description here

enter image description here

enter image description here

Upvotes: 3

Alexis Pavlidis
Alexis Pavlidis

Reputation: 1080

If you have a maven project you can import the library by inserting the dependency entry of the library to the dependencies like this:

<dependency>
    <groupId>org.reflections</groupId>
    <artifactId>reflections</artifactId>
    <version>0.9.12</version>
</dependency>

If you don't have a pom.xml, you can insert the .jar through Intellij. Everything that is deployed to the Maven Central Repository has a .jar produced.

So you can go to the project structure by Ctrl + Alt + Shift + S and on the Modules menu on the left you can press the + icon and then select from Maven.... On the field of the pop up you can insert the name of the library, search for it, and then press OK.

If you want to import it manually (not recommended) you can download the .jar directly from the Maven Central Repository here. When you download it you just go to the project structure like before and you just select Java instead of from maven.

Upvotes: 4

Alexandru Somai
Alexandru Somai

Reputation: 1405

The best approach for that would be to use Maven (or Gradle).

But, if you really want to download the .jar file and import that one into IntelliJ, you can download it from Maven Central, here: https://mvnrepository.com/artifact/org.reflections/reflections/0.9.12.

enter image description here

Or, alternatively, just follow this link: https://repo1.maven.org/maven2/org/reflections/reflections/0.9.12/ and get the .jar from there.

Upvotes: 2

Related Questions