How to show line numbers in Eclipse IDE

In this article, we will discuss how to enable/display line numbers in Eclipse IDE for any files like .java, .xml or .jsp

Why it is needed?

  • Whenever, any exception or errors are thrown while executing Java program, then server console prints exception/error stack-trace along with its location i.e.; line number
  • To fix this, we need to search using line number
  • Note: by default Eclipse IDE doesn’t comes with line numbers enabled
  • So, we need to explicitly enable this using 2 options

 

Enable Line Numbers using 2 options:

  1. Using Menu option in Eclipse IDE
  2. By right-clicking mouse and enabling line numbers (CTRL + F10)

 

Option 1: Enable using Menu option

Eclipse IDE –> Windows –> Preferences –> General –> Editors –> Text Editors –> check line number (option)

 

Option 2: Right-click –> enable line numbers

Alternatively, we can enable by right-clicking mouse and selecting the option “show line numbers

 

Instead of right-clicking, we can also use short-cut keys supported in Eclipse IDE. Like, for enabling line numbers press CTRL + F10 simultaneously and check the option “show line numbers

 

References:

 

Happy Coding !!
Happy Learning !!

How to remove unused imports in Eclipse IDE
Java compiler compliance level issue in Eclipse IDE