Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an external jar library to Intellij IDEA

I'm having a silly problem : I'm trying to add the Jsoup library (which is just an external jar) to my android application developed in Intellij Idea and it seems and don't do it right . I put the library in the libs folder , then I went in Project Structure -> modules and selected dependencies , select add global library , select attach source and click ok.

When I write code it is able to automatically import classes and to compile , but when running I get " java.lang.NoClassDefFoundError: org.jsoup.Jsoup"

like image 695
steve Avatar asked May 17 '11 09:05

steve


People also ask

How do I Import an external library into IntelliJ?

From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to add a library and click Dependencies. button and select Library. In the dialog that opens, select a project or a global library that you want to add to the module.

How manually add jar in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Modules | Dependencies. Alt+Insert and select a dependency type: JARs or directories: select a Java archive or a directory from files on your computer.


3 Answers

  • Copy the .jar file into your lib/ directory.
  • Right click the new .jar in the lefthand file browser in IntelliJ / Android Studio
  • Choose "Add as Library..."
  • Voila!
like image 67
Alfie Hanssen Avatar answered Nov 15 '22 00:11

Alfie Hanssen


-Open the External Libraries node on the Left hand panel. -Select Open Library Settings -Project structure dialogue opens up. Select the Libraries. Click the "+" to browse the file.

![add external jar1

like image 39
Ronald Nsabiyera Avatar answered Nov 15 '22 00:11

Ronald Nsabiyera


In IntelliJ IDEA 15 you can also access the Project Structure menu item from "File" item in the menu bar. Select Libraries from the list on the left. Click the "+" to browse the file, select it and you're done. It will be added to the "External Libraries" directory in your project.

like image 1
bob Avatar answered Nov 15 '22 01:11

bob