Reputation: 198238
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 ?
Upvotes: 15
Views: 4033
Reputation: 2571
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.
Upvotes: 8