12

Is there a way to count the number of lines of code in an eclipse project? I can see the total number of lines for each file, but I'd like to see how much is generated across the whole project.

3 Answers 3

13

Check out the Eclipse Metrics plugin.

alt text

Note the 'Lines of code' statements.

Edit: Version 2 of Metrics, requiring Eclipse 3.5+, is available here http://metrics2.sourceforge.net/

1
  • I tried and it is not working for me. I have installed plugin from Eclipse marketplace, and no luck.. Please help!
    – Paresh
    Commented May 6, 2015 at 16:32
1

You need to use the JavaNCSS tool, see JavaNCSS - A Source Measurement Suite for Java

I can't find any working links to Eclipse plugins that incorporate this library, only stale broken links.

But you can run it:

Also see JCSC which includes NCSS.

0

I've generally just used find and wc under Cygwin.

3
  • One liner for total count : find src -type f | xargs cat |wc -l Commented Nov 20, 2019 at 15:33
  • one liner for each file: for x in $(find src -type f) ; do printf $x ; printf " -> " ; cat $x | wc -l ; done; Commented Nov 20, 2019 at 15:34
  • IMHO this is better since you only count lines of java files and make find use cat by itself: find . -type f -name '*.java' -execdir cat '{}' \; | wc -l
    – Lorenzo
    Commented Mar 26, 2023 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .