Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we find orphan jars in intellij idea project

I have found useful tools to do this in eclipse like Classpath Helper, but is there any plugin or way in intellij idea to find unused jar files ?

like image 998
Raheel Avatar asked Jun 07 '13 11:06

Raheel


People also ask

How do I find the class name for a jar in IntelliJ?

In IntelliJ IDEA, we can press on the keyboard SHIFT key twice to open a search everywhere windows to quickly find a class or a file. Other shortcuts, seldom use, prefer double clicks on SHIFT key to open the search windows. Ctrl+N – finds a class by name. Ctrl+Shift+N – finds a file or directory by name.

Can we open jar file in IntelliJ?

File > Project Structure... or press Ctrl + Alt + Shift + S. Project Settings > Modules > Dependencies > "+" sign > JARs or directories... Select the jar file and click on OK, then click on another OK button to confirm. You can view the jar file in the "External Libraries" folder.


2 Answers

I'm sure you know how to use the IDEA Dependency Analysis tool to find library dependencies, and while that could get you some of the way it's of course not enough.

The problem and fact is that there is no way of finding unused JARs by way of static analysis, since it is possible to refer to and create any class in any dependency by way of reflection/IoC/whatnot these days.

So, the best you can "hope" for is a tool that can tell which JARs are not explicitly referenced by your code - curiously that is absent from IDEA as far as I know (but I would love to be corrected on that point!)

Cheers,

like image 193
Anders R. Bystrup Avatar answered Sep 19 '22 11:09

Anders R. Bystrup


You should really be using maven and determining each module's dependencies manually. Classpath Helper is an astonishingly bad way to tell what jars you're using.

like image 22
Software Engineer Avatar answered Sep 20 '22 11:09

Software Engineer