如何在JVM中设置默认语言环境? [英] How do I set the default locale in the JVM?
问题描述
我想将我的JVM的默认Locale
设置为fr_CA
.有什么可能的选择呢?
I want to set the default Locale
for my JVM to fr_CA
. What are the possible options to do this?
我只知道一个选项Locale.setDefault()
推荐答案
来自 Oracle参考:
应用程序的默认语言环境是通过三种方式确定的. 首先,除非您明确更改了默认设置,否则
Locale.getDefault()
方法返回的语言环境最初是确定的 由Java虚拟机(JVM)首次加载时由其提供.那就是 JVM从主机环境中确定默认语言环境.主人 环境的语言环境由主机操作系统和 在该系统上建立的用户首选项.
The default locale of your application is determined in three ways. First, unless you have explicitly changed the default, the
Locale.getDefault()
method returns the locale that was initially determined by the Java Virtual Machine (JVM) when it first loaded. That is, the JVM determines the default locale from the host environment. The host environment's locale is determined by the host operating system and the user preferences established on that system.
第二,在某些Java运行时实现中,应用程序用户可以
通过在以下位置提供此信息来覆盖主机的默认语言环境
通过设置user.language
,user.country
和
user.variant
系统属性.
Second, on some Java runtime implementations, the application user can
override the host's default locale by providing this information on
the command line by setting the user.language
, user.country
, and
user.variant
system properties.
Third, your application can call the Locale.setDefault(Locale)
method. The setDefault(Locale aLocale) method lets your application
set a systemwide (actually VM-wide) resource. After you set the default locale with this
method, subsequent calls to Locale.getDefault() will return the newly
set locale.
这篇关于如何在JVM中设置默认语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!