Eclipse IDE – How to show line numbers ?

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

Q) 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

1. Enable Line Numbers using 2 options:

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

1.1 Enable using Menu option

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

1.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

2. Useful Eclipse IDE shortcuts :

Related Articles:

References:

Happy Coding !!
Happy Learning !!

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