How to set the default locale to a JVM

Java uses the computer default locale by default. The default locale can be changed in the JVM by passing a parameter.

Run the following command:

java -Duser.language=LANGUAGE


Here is an example calling the help from Java on a computer with English as the default language. The message returned is in English.

olivier@server:~# java -h
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

Here is the same call to java passing the parameter setting the JVM to Japanese. The returned message is in Japanese.

olivier@server:~$ java -Duser.language=ja -h
使用方法: java [-options] class [args...]
   または  java [-options] -jar jarfile [args...]



Java Help

Recent Comments