Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Jar files to IntellijIdea classpath

I have created a new Intellij project. But I can't use the third party jars in my project. I have the jars in a directory structure as follows:
repository/commons-logging/commons-logging-1.0.4.jar
repository/commons-lang/commons-lang-2.1.jar
etc.

I want to add them just by pointing to the repository directory, but couldn't find any ways to add them. But when I am using classes or API from that jars, the editor can't resolve the classes. I have tried from Project Structure but can't configure it.

like image 612
java developer Avatar asked May 24 '13 19:05

java developer


People also ask

How do I add jar to runtime classpath in IntelliJ?

Go to File-> Project Structure-> Libraries and click green "+" to add the directory folder that has the JARs to CLASSPATH. Everything in that folder will be added to CLASSPATH.

How do I add jar files to Tibco BW 6?

In TIBCO Business Studio, click File > New > Project. In the New Project dialog, click the Plug-in Development folder, and then click Plug-in from Existing JAR Archives. Click Next. In the Plug-in from Existing JAR Archives dialog, click Add to add the third-party JAR files.


2 Answers

Go to File-> Project Structure-> Libraries and click green "+" to add the directory folder that has the JARs to CLASSPATH. Everything in that folder will be added to CLASSPATH.

Update:

It's 2018. It's a better idea to use a dependency manager like Maven and externalize your dependencies. Don't add JAR files to your project in a /lib folder anymore.

Screenshot

like image 182
duffymo Avatar answered Sep 28 '22 04:09

duffymo


If, as I just encountered, you happen to have a jar file listed in the Project Structures->Libraries that is not in your classpath, the correct answer can be found by following the link given by @CrazyCoder above: Look here http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html

This says that to add the jar file as a module dependency within the Project Structure dialog:

  1. Open Project Structure
  2. Select Modules, then click on the module for which you want the dependency
  3. Choose the Dependencies tab
  4. Click the '+' at the bottom of the page and choose the appropriate way to connect to the library file. If the jar file is already listed in Libraries, then select 'Library'.
like image 37
vinegarbin Avatar answered Sep 28 '22 06:09

vinegarbin