score:0
Just use Analyze | Inspect Code with appropriate inspection enabled (Unused declaration under Declaration redundancy group).
Using IntelliJ 11 CE you can now "Analyze | Run Inspection by Name ... | Unused declaration"
score:1
ProGuard can be used to print a report of unused classes/methods. It's a pain to supply all the dependent jars to it, though.
These options list unused classes, fields, and methods in the application mypackage.MyApplication:
-injars in.jar
-libraryjars <java.home>/lib/rt.jar
-dontoptimize
-dontobfuscate
-dontpreverify
-printusage
-keep public class mypackage.MyApplication {
public static void main(java.lang.String[]);
}
score:86
I also like to use UCDetector:
UCDetector (Unecessary Code Detector) is a Open Source eclipse PlugIn Tool to find unecessary (dead) public java code. It also tries to make code final, protected or private.
Bonus: it can also find cyclic dependencies between classes
(also a number of other tools -- including Findbugs -- knows how do do that too)
Caveat: Cid mentions in the comments:
UCDetector shall not work if there are interface implementations which will be known only at runtime.
It incorrectly marks the implementation classes as unused.
Update 2017: static code analysis has evolved quite a bit in 8 years.
Using SonarLint for Eclipse, you can use the the latest SonarJava 4.6 plugin to analyze your code.
It will find dead code.
Source: stackoverflow.com
Related Query
- Find unused classes in a Java Eclipse project
- How to find unused Java classes and JSP files from a project
- Running Gradle project via Eclipse errors "system Cannot find System Java Compiler"
- How to quickly find the main() in java project using eclipse ?
- Inside Eclipse Android project run Java classes with main(String[] args) as Java Application causes "Invalid layout of java.lang.String at value"
- Maven java project in eclipse doesn't see classes in same package
- Use sun.* classes in Eclipse Java project
- Find unused variables in Flash Builder 4 (like Eclipse for Java does)
- Eclipse find all java classes that have no tests in them
- get all the classes with main method in Eclipse Java project
- Access classes from one project in another Java Web project in Eclipse
- import java classes into jsp project in eclipse
- java eclipse patched JRE classes Xbootclasspath Could not find or load main class
- Eclipse plug-in development, expose plug-in's classes in java project
- java eclipse mars libgdx cannot find main on my desktop project package to run a gamescreen
- Auto import new Java classes added to project path on startup in Eclipse
- Remove classes that are not in use from Android or/and Java project in Eclipse
- Can I have classes with same name in one Java project in Eclipse IDE?
- How export an Eclipse project including IBM classes for Java libraries into an executable JAR
- Cannot run Eclipse Java project in visual studio code (Could not find or load main class)
- Cannot find a resource file, after exporting java project as JAR, and trying to use it in a Dynamic Web Project in ECLIPSE
- How to find web project path from Eclipse in Java file?
- remove unused tag library (prize tag) from Eclipse Java project
- Eclipse Project Access Java Core Classes On Mac OS X
- eclipse doesn't create java classes from wsdl into current project
- Eclipse IDE started and broken - cannot find any Java classes
- Eclipse - Using classes from another java project but same package for testing purposes
- GWT plugin - Eclipse Kepler 4.3 - cannot find toolbar button as "create a Java project with GWT support"
- eclipse java content assisst doesn't work for particular class, work for other classes in project
- Eclipse PDE project with java classes generated from WSDL file with Apache-Axis
More Query from same tag
- BlueJ packaged Jar isn't working
- Apache Nutch 1.9 in local Eclipse to run on Amazon EMR remotely
- Eclipse project files compatibility with previous versions of Eclipse?
- correct way to use scm element in pom.xml?
- auto completion on generated java code in eclipse
- ID Types in hibernate
- How to interact with Fuseki using Java in Eclipse
- Simple Glassfish RESTful service in eclipse throws exception
- Adding Richfaces to Eclipse Palette?
- How do I reference an external library in Java?
- eclipse 4 application part not appear
- Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved
- Why is javafx.mail.jar Java library not found in my IDE?
- Make a own interpreter for a Xtext grammar
- Haxe/OpenFL in FlashBuilder/Eclipse?
- How to startActivity from Options Menu
- maven project which has both java and scala
- Why my program works on JFrame but not on JApplet?
- Eclipse m2e plugin stopped changing classpath to add dependencies
- Eclipse RCP - usage of help subsystem
- Difficulty in adding GITHUB to eclipse
- How to configure mySQL on Eclipse EE (Java)
- Can't set Android target after update sdk rev.21 in Eclipse
- SWT: Changing the color of all the cells under a column
- How to use CoffeeScript and Eclipse together in Windows?
- Using cvs add command in Ant to 'update' a module
- Very simple step by step JBehave setup tutorial?
- Bukkit API Soft Depend Importing
- Conditional proxy re-direction in Eclipse?
- eclipse weblogic outbound calls