Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding folder to Eclipse classpath

Tags:

java

eclipse

While developing a Java project, I place all of my jar files in a folder, created within my project, called libs. Now, is there a way to add my libs folder to the Java class path so that I do not have to add each individual jar?

I was thinking something along the lines of a variable or creating a user library.

like image 518
Paul Avatar asked Mar 16 '10 21:03

Paul


People also ask

How do I add an extra library to my project's classpath?

Open the context menu on the project, and select Properties > Java Build Path > Libraries. From here, you can add JAR files to the build path, whether they are inside your workspace or not. You can also add a class folder, a directory containing Java class files that are not in a JAR.

What is classpath in Eclipse project?

The . classpath maintains the project's source and target references for Java compilation and compressed file or project dependencies. This configuration is maintained through the Java Build Path page in the project's properties.


1 Answers

Based on what you've said, I would probably create a user library containing your library JARs.

You can create a User Library with Window => Preferences, drill down to Java => Build Path => User Libraries. => Then choose New, and give your library a name => Then add the JARs you want.

Then you can add all the JARs to the classpath of any project you have by right-clicking on the project => Add Libraries => User Libraries, and selecting your library.


Update; to have Eclipse dynamically add .jar files you drop into a folder to your project classpath, you need a plugin called Library Folder ClasspathContainer. Follow these instructions and you're in business.

like image 109
brabster Avatar answered Sep 30 '22 21:09

brabster