JavaNCSS - A Source Measurement Suite for Java


Ever wondered how many lines of code or how many classes there are in  the Sun JDK? Curious about the size of your own projects - or do you want to keep track of your work-progress. That's what JavaNCSS is for.

JavaNCSS is a simple command line utility which measures two standard source code metrics for the Java programming language. The metrics are collected globally, for each class and/or for each function.

Here is an example about what JavaNCSS prints out for the Sun JDK 1.1.5 java.* source tree (update: JDK 1.5 api source tree consists of 569'830 ncss).

JavaNCSS can optionally present its output with a little graphical user interface. To interactively select Java source files for counting, Jacob (a Java class browser and project manager) can be used for this purpose.

JavaNCSS can also be used out of an Ant build.xml script as it comes bundled with an Ant task written by Steve Jernigan. The JavaNCSS Ant Task is documented on a separate page.

You can always find the newest version of this page at: http://javancss.codehaus.org/ (was previously at http://www.kclee.de/clemens/java/javancss/).

Features and Metrics JavaNCSS Provides

  • Metrics can be applied to global-, class-, or function-level.
  • Non Commenting Source Statements (NCSS).
  • Cyclomatic Complexity Number (McCabe metric).
  • Packages, classes, functions and inner classes are counted.
  • Number of formal Javadoc comments per class and method.
  • Average values are calculated.
  • Command line driven.
  • A GUI is provided for better output browsing as well as the integration of JavaNCSS in a project manager and class browser named Jacob for easy selection of input source files.
  • XML output (optional).
  • XSLT stylesheets provided for further generation of HTML, and SVG reports and as a basis for your own custom reports.
  • Ant task (written by Steve Jernigan).
  • Support for Java 1.5 syntax (generics, enums, etc.).
  • 100% Pure Java.
  • Free software (GNU LGPL).

System Requirements

Java JDK >= 5