Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a source code library to IntelliJ (For example from Github)?

I want to add this library from Github to a new Java project. https://github.com/jmdns/jmdns

I have searched and found only methods to add jars and not source code of libraries.

How do I add source code of libraries and import from them in my project in Intelli.

It'd be cool if the library above was specified as an example.

like image 332
Kotlinboy Avatar asked Oct 24 '25 08:10

Kotlinboy


1 Answers

I found an answer on my own using two other QnAs on SO.

1) First you need to create a separate project containing the source of the library and compile it as jar.

If it's from Github you can just select File-> New-> Project from version control-> Git and create a new project from the github source.

Then you need to compile it as jar or artifact in Intellij

Look at this question for that:

How to build jars from IntelliJ properly?

2) Then you need to open your project from which you want to import the jar or library and add it to the project and add it or register it as library.

Look here for that: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

After doing these two steps I was successfully able to import the library.

like image 144
Kotlinboy Avatar answered Oct 26 '25 22:10

Kotlinboy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!