Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Remove/Add jar to all projects in eclipse workspace

I have recently upgraded a framework I am developing with and one of the jars from the old install has been upgraded to a newer version (i.e. the name of the jar is different).

All of the (200+) projects in my workspace depend on this jar and so now are displaying the following two errors:

  1. "Project 'Blah' is missing required library"
  2. "The project cannot be build until build path errors are resolved"

It will take me a substantial amount of time to modify the build path of every project in my workspace, firstly removing the incorrect jar and then adding the new one.

Is there a way to add/remove a jar to all (or a group of) projects in one go?

This question illustrates adding jars using libraries - something I could use going forward but doesn't fix my current problem.

I am running Eclipse Mars 4.5.0

like image 211
ferekdoley Avatar asked Sep 29 '15 11:09


People also ask

How do I remove jar files from project and external dependencies?

Select Project in Project Explorer and Press "Alt+Enter" then Go to Java Build path and select Libraries then select jar file finally click on Remove button. select jar in the Project tree-view and right click on it and select Build Path then in select the Remove from Build Path . You are done.

How do I remove a project from my workspace in Eclipse?

Procedure. In the Eclipse Navigator view (or any Eclipse view that supports Team operations), navigate to the project that you want to remove. Right-click the project and click Team > Delete from Repository Workspace.

How do I remove a classpath library?

Open the Libraries tab. Find the entry in the list of libraries called Shared Library [<library-name>] and select it. Click Remove.

How do I remove all projects from project Explorer in Eclipse?

To delete a project, right-click on the project in the Package Explorer. Again, select “Delete” from the context menu. To delete your project select the option “Also delete contents under…” and select “Yes.”

2 Answers

On the back of Chandrayya G K's answer I have found a simple solution to solve my issue that doesn't involve creating extra projects etc. - Simply find and replace the reference to the jar in the classpath.

Within eclipse press Ctrl+H to bring up the Search Window.

enter image description here

Click File Search Tab

In the "Containing text:" field enter the classpathentry tag that references the old jar. This can be found in the .classpath file within any of your eclipse projects. Mine looks like this:

<classpathentry kind="lib" path="C:/myjars/old-jar.jar"/>

You can then specify .classpath in "File name patterns" field to limit your search to the classpath files.

Restrict "Scope" to the whole workspace.

Click Replace

In the Replace window enter your classpathentry tag that points to your new jar.

enter image description here

Click OK.

*If you don't have an old jar that needs replacing you can just replace the end </classpath> Tag with <classpathentry kind="lib" path="C:/myjars/new-jar.jar"/> </classpath> to insert a reference to the new jar.

like image 178
ferekdoley Avatar answered Oct 12 '22 07:10


Yes there is way. Create one common project to hold all common libraries used by all projects(call it as test1). Create a folder lib and copy all libraries here. Right click on the properties of this project add all these libraries to build path. enter image description here

Make all projects depend on this project. How?

Each project has a file called .classpath in its folder. We need to tweak it.

Press Ctrl + H.

Enter "</classpath>" in "Containing text" text box.

Check "Regular expression" button.

In "Filename patterns" text box enter ".classpath"

Click on Search button.

In Scope choose "workspace".

In Search view all files will be displayed. In Search view menu choose "Show as List" option.

Now with the help of Ctrl and Shift keys you can easily select/deselect many item. Select all items you want to make them to dependent on test1.

Right click and choose "Replace Selected". Enter data as shown below

enter image description here

Note: Here I choose Java project. In case of other project type you need to find out string to replace by adding dependency using UI.

That's it you can add and remove common libraries in test1 project. But be careful while exporting project. I haven't tested it but hope it works after export also. Please let me know in case its not working.

enter image description here

like image 40
Chandrayya G K Avatar answered Oct 12 '22 09:10

Chandrayya G K