如何设置JVM的默认语言环境? [英] how do I set the default locale for my JVM?

查看:834
本文介绍了如何设置JVM的默认语言环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的JVM的默认语言环境设置为fr_CA。有什么可能的选择呢?



我只知道一个选项 Locale.setDefault()

解决方案

来自 Oracle Reference


应用程序的默认语言环境以三种方式确定。
首先,除非您明确更改了默认值,否则
Locale.getDefault() 方法返回Java虚拟机(JVM)最初确定
时的区域设置它首先加载。也就是说,
JVM确定主机环境的默认语言环境。主机
环境的语言环境由主机操作系统确定,
由在该系统上建立的用户首选项确定。



其次,在一些Java运行时实现上,应用程序用户可以
通过设置 user.language ,<$ c $在命令行
上提供此信息来覆盖主机的默认语言环境c> user.country ,
user.variant 系统属性。



<第三,您的应用程序可以调用 Locale.setDefault(Locale)
方法。 setDefault(Locale aLocale)方法允许您的应用程序
设置系统范围的(实际上是VM范围的)资源。使用此
方法设置默认语言环境后,对Locale.getDefault()的后续调用将返回新的
设置语言环境。



I want to set the default Locale for my JVM to fr_CA. What are the possible options to do this?

I know of only one option Locale.setDefault()

解决方案

From the Oracle Reference:

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.

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屋!

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