What does $NON-NLS-1$ mean?

paulgreg picture paulgreg · Mar 17, 2009 · Viewed 73.5k times · Source

In Eclipse source code, I've found some '$NON-NLS-1$' in comments used like that :

private String toolTip = ""; //$NON-NLS-1$

What does that mean ?

Answer

Aaron Maenpaa picture Aaron Maenpaa · Mar 17, 2009

They silence a warning that Eclipse emits when it encounters string literals (and has been configured to complain).

The idea is that UI messages should not be embedded as string literals, but rather sourced from a resource file (so that they can be translated, proofed, etc). Consequently, Eclipse can be configured to detect string literals, so that you don't accidentally have leave unexternalized UI strings in the code; however, there are strings which should not be externalized (such as regexps) and so, //$NON-NLS-1$ gives you a way to communicate that fact to the compiler.