15

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?

ajduke
  • 4,991
  • 7
  • 36
  • 56
littlejedi
  • 969
  • 1
  • 13
  • 23
  • 4
    Where is the exception coming from? Is it using a message given to it by the OS? If so you need to change the language at the OS level. – Peter Lawrey Jun 18 '13 at 01:42
  • How strange. What sort of exception? Is it from some Chinese library? Did you download a Chinese Java? – Boann Jun 18 '13 at 05:12
  • thanks guys, this is what I see from the exception: java.io.IOException: {chinese message here} The chinese message is equivalent to " An existing connection was forcibly closed by the remote host". I wonder if this is OS level thing, like what Peter said... – littlejedi Jun 23 '13 at 22:19
  • are you able to resolve this problem? – macemers Feb 07 '23 at 07:33

2 Answers2

3

"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?

Boann
  • 48,794
  • 16
  • 117
  • 146
0

Throwable.getLocalizedMessage() might work, assuming that the library you're using provides localized exception messages.

Matthew Cline
  • 2,312
  • 1
  • 19
  • 36