简体   繁体   中英

Is there a way to force exception message to be English for Java 1.7

I've almost tried everything including:

  1. Change system region and language to be 'english US'
  2. Use Locale.setDefaultLocale()
  3. Pass in JVM arguments

It prints out:

Default locale is : en_US

BUT my application is still throwing exception with Chinese exception message

Does this have anything to do with Spring? (my app is based on Spring, but there is no locale-related config whatsover, so it should be just using whatever is default)

Can anyone help me with this?

UPDATE:

I'm basically getting a java.io.IOException with Chinese message equivalent to

An existing connection was forcibly closed by the remote host

changing the locale didn't seem to affect this, maybe this is indeed an OS level thing?

"An existing connection was forcibly closed by the remote host" is a standard error message from the Windows Sockets library (code 10054).

In retrieving the error message for the error code, the specification of the FormatMessage function says it will take the user or system locale into account. As far as I know, setting the system region and language to English US should do that. Perhaps a Chinese version of Windows just doesn't have English language messages available?

Throwable.getLocalizedMessage()可能有效,假设您使用的库提供了本地化的异常消息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM