1

I tried to generate javadoc using the command line tool, i.e.:

javadoc Main.java

But the resulting documentation is in Chinese for me.

How can I change the language to, lets say English?

Zabuzard
  • 25,064
  • 8
  • 58
  • 82
RR Carol
  • 11
  • 1

1 Answers1

0
javadoc -locale en_US Main.java

See the official documentation of the command.

In particular the section about the -locale option:

-locale name

Specifies the locale that the javadoc tool uses when it generates documentation. The argument is the name of the locale, as described in java.util.Locale documentation, such as en_US (English, United States) or en_US_WIN (Windows variant).

Specifying a locale causes the javadoc tool to choose the resource files of that locale for messages such as strings in the navigation bar, headings for lists and tables, help file contents, comments in the stylesheet.css file, and so on. It also specifies the sorting order for lists sorted alphabetically, and the sentence separator to determine the end of the first sentence. The -locale option doesn't determine the locale of the documentation comment text specified in the source files of the documented classes.

Zabuzard
  • 25,064
  • 8
  • 58
  • 82
  • 1
    It's English now. Thank you very much! – RR Carol Jun 02 '22 at 10:11
  • Actually, for me this setting has absolutely no effect, e.g. it says "Klasse" (German) instead of "Class" and something like "Methodenübersicht" (method overview). I am not talking about the actual javadoc texts as such, but the language of the javadoc template itself. The only way to change the behaviour was to run `javadoc -J-Duser.language=en` or, when using tool provider API, the JVM with `-Duser.language=en`. How can I set that during runtime? Since JDK 20, it otherwise uses my German locale by default. – kriegaex Mar 29 '23 at 10:22
  • OK, I just found the answer: `Locale.setDefault(Locale.ENGLISH)`, see also [this answer](https://stackoverflow.com/a/8809162/1082681). – kriegaex Mar 29 '23 at 10:28