How to count lines of Java code using IntelliJ IDEA?
Solution 1:
The Statistic plugin worked for me.
To install it from Intellij:
File - Settings - Plugins - Browse repositories... Find it on the list and double-click on it.
Access the 'statistic' toolbar via tabs in bottom left of project
OLDER VERSIONS: Open statistics window from:
View -> Tool Windows -> Statistic
Solution 2:
Quick and dirty way is to do a global search for '\n'
. You can filter it any way you like on file extensions etc.
Ctrl-Shift-F -> Text to find = '\n'
-> Find.
Edit: And 'regular expression' has to be checked.
Solution 3:
In the past I have used the excellently named MetricsReloaded plugin to get this information.
You can install it from the JetBrains repository.
Once installed, access via: Analyze -> Calculate Metrics...
Solution 4:
Although it is not an IntelliJ option, you could use a simple Bash command (if your operating system is Linux/Unix). Go to your source directory and type:
find . -type f -name '*.java' | xargs cat | wc -l
Solution 5:
Just like Neil said:
Ctrl-Shift-F -> Text to find =
'\n'
-> Find.
With only one improvement, if you enter "\n+"
, you can search for non-empty lines
If lines with only whitespace can be considered empty too, then you can use the regex "(\s*\n\s*)+"
to not count them.