是否有一种方法可以将Java 1.7的异常消息强制为英语 [英] Is there a way to force exception message to be English for Java 1.7

查看:90
本文介绍了是否有一种方法可以将Java 1.7的异常消息强制为英语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎尝试了所有事情,包括:

I've almost tried everything including:

  1. 将系统区域和语言更改为英语"
  2. 使用Locale.setDefaultLocale()
  3. 传递JVM参数

它打印出来:

Default locale is : en_US

但是我的应用程序仍然抛出带有中文异常消息的异常

BUT my application is still throwing exception with Chinese exception message

这和Spring有什么关系吗? (我的应用程序基于Spring,但是没有与语言环境相关的配置问题,所以应该使用默认设置)

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)

有人可以帮我吗?

更新:

我基本上得到的java.io.IOException的中文信息等于

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?

这篇关于是否有一种方法可以将Java 1.7的异常消息强制为英语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆