I have seen many questions on Stackoverflow with the tag but without the tag. As a result the code was not highlighted, because of the missing code-tag. I would like to see the Java-code highlighting implemented as a default into the tag, so the code gets highlighted even without the tag to Java unless an other laguage-tag is provided.

Although the tag could be used by Scala code this is in less than 1% the case and the default is Java.

This was done for and -highlight although CUDA can be used by other program languages with wrappers. Compare Default syntax highlighting for [CUDA] questions

Maybe there are other unmistakable tages.

  • 7
    I've got JUnit tests in Scala. It's not always guaranteed to be Java.
    – Makoto
    Sep 26, 2012 at 1:13
  • 1
    In such cases, you should always pair the tag with the appropriate language tag.
    – Mysticial
    Sep 26, 2012 at 1:16
  • 3
    It's my point then that one can't assume that JUnit exclusively refers to Java. There may be some unmistakable tags, but this is one of those cases in which a hole in logic is observed.
    – Makoto
    Sep 26, 2012 at 1:17
  • 1
    You can always enforce highlighting with language hints, see meta.stackexchange.com/a/75019/167534
    – bfavaretto
    Sep 26, 2012 at 1:30
  • this request if for the users, which forget to add the laguage-tag
    – Simulant
    Sep 26, 2012 at 1:41
  • 3
    Then you should just add the tag whenever you see it. There isn't much you can automatically do for people who aren't tagging properly.
    – Mysticial
    Sep 26, 2012 at 1:53
  • 3
    To add some numbers to this discussion: of the 3,883 questions currently tagged JUnit fully 40% are not tagged java. (I don't have any numbers for how many are tagged, e.g., Scala.)
    – blahdiblah
    Sep 26, 2012 at 1:56

2 Answers 2


JUnit was originally developed for Java, so I don't think auto-tagging with lang-java would be inappropriate. The JUnit website doesn't even mention the word Scala, if my Google-fu is accurate.

I also believe that those using Scala are more adjusted to the idea that Java technologies can work with Scala. By contrast, many Java programmers will be unfamiliar with Scala and wouldn't know the distinction is required.

Whatever is decided, I've edited the junit tag excerpt to suggest the corresponding language tag is added.

To continue with the numbers started by blahdiblah in the comments (as of 16th Dec 2012):

  • Total JUnit questions: 4,402
  • of which tagged Java: 2,547 (58%)
  • of which tagged Scala: 31 (0.7%)
  • not tagged Java or Scala: 1,831 (42%)

Considering only the tagged questions, then 98.7% of all JUnit questions are Java-related. And note, this figure is likely to be corrupt in favour of Scala - Scala users are very likely to tag their questions appropriately because they are aware readers will assume they are using Java.

I think a language hint that suits at least 98% of the questions asked is quite appropriate. Especially when the minority group are more likely to tag their questions appropriately.

  • I disagree. JUnit is a framework based on the JRE and therefor language agnostic. Adding a language hint to it is as inappropriate as adding a language hint to [.net] (for C#). Dec 17, 2012 at 10:57

If it has to do with java, you should retag it (via suggested edit if you don't have the rep) with . You can also add <!-- language: lang-java --> above the code blocks. While you're at it, add the tags to the appropriate ones.

  • 3
    I know how to do this. Bu wouldn't it be easier if I don't have to retag every 5th junit-Question?
    – Simulant
    Sep 26, 2012 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .