My system is Chinese, and when there is an error occurs in my java program, it may output non-English error messages which is unreadable:
Caused by: java.io.IOException: CreateProcess error=2, 系统脮也禄碌陆指露
or:
IOException occured : Cannot run program "cmd /C tsc hello.ts":
CreateProcess error=2, ϵͳÕҲ»µ½ָ¶
Is it possible to let java always output English error messages ?
setDefault(java. util. Locale. ENGLISH); JFileChooser chooser = new JFileChooser(); chooser.
Localization is the process of adapting software for a specific region or language by adding locale-specific components and translating text.
Depends on the app. A highly technical application that will be used by people that understand English and the target language, you might be OK with English error messages. If it's a message that will be seen by the end user, it should be translated.
There are two parts to the answer.
Java displays error messages based on the default locale. There are three system properties which define the default locale: user.language
, user.country
and user.variant
. If you have access to your Java VM command line you can set these properties using the -D
command line switch. E.g. this is enough to switch Java to generic English:
java -Duser.language=en com.my.Class
You can define a JAVA_TOOL_OPTIONS
environment variable and specify your options there. Any JVM starting in such environment will pick these options up as if they were on the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With