This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Since we do not hand out ready made code here at the Ranch, I will share some pseudo code with you.
1) Open a stream to the. For this you can either use BufferedReader or Scanner
2) Read one line at a time
3) Increment the counter
4) When you finish reading the file, the counter will tell you the number of lines.
This is basic stuff. You need to build logic for identifying if the read line is empty and if the read line was part of some comment.
You have also failed to take into consideration the package statement and import statements. If you ignore them, your code is going to be flawed.