The rule of thumb is that you should put the programming language that relates to your question. In the case of your specific question, I would have put java among the tags.
However, in general, there exist some exceptions where adding a language-specific tag can drive away people who could answer your question. Here's one example. Selenium is a project that has produced libraries that allow you to drive web browsers. So you can write code that will open a web page, find a link, click on it, etc. and it will be able to control Firefox, Chrome, IE, whatever... These libraries exist in multiple languages: Java, Python, C#, Ruby, JavaScript, etc. The fact is that the vast majority of Selenium questions posted on SO are about problems that belong to Selenium proper, irrespective of the language that one uses. And since the API is quite regular from language to language, it is easy for someone who has never programmed in a given language (but who is not a novice at software languages in general) to still understand questions or answers written in that language. I have answered Selenium questions in languages I've never used.
So in a case like this, an OP who does not care what language is used to answer the question could skip the language-specific tag so as to avoid driving away people who do not know that specific language but could otherwise answer the question.
<!--- language: lang-java --->
or whatever you need, that isn't reason enough to add tags.