简体   繁体   English

如何设置java keytool的默认语言?

[英]How to set default language for java keytool?

I use Windows OS with English language and US keyboard setting. 我使用带有英语和美式键盘设置的Windows操作系统。 I use this command to generate keystore. 我使用此命令生成密钥库。 It works fine. 它工作正常。

C:\java6\jre\bin\keytool -genkey -keyalg RSA -alias mykey -validity 3652 -keystore C:\mykeystore -storepass 111111111 < data.txt

The data.txt data.txt

My name
My org unit
My org
My city
My state
ch
yes

However, this program cannot work normally on Windows with German language and keyboard setting. 但是,此程序无法在具有德语和键盘设置的Windows上正常工作。 I must change the word " yes "" to " ja " in data.txt to make it works. 我必须在data.txt中将“ yes ”改为“ ja ”,以使其有效。

It isn't good to modify the data.txt. 修改data.txt是不好的。

Is there any way to set English as default language for keytool? 有没有办法将英语设为keytool的默认语言?

In a nutshell you must pass the -Duser.language=en option to the Java machine. 简而言之,您必须将-Duser.language=en选项传递给Java机器。 I know of two ways to do this: 我知道有两种方法可以做到这一点:

  1. For just one invocation, specify the -J-Duser.language=en option on the keytool command line, eg 对于一次调用,请在keytool命令行中指定-J-Duser.language=en选项,例如

     keytool -J-Duser.language=en -genkey -keyalg RSA -alias mykey -validity 3652 -keystore C:\\mykeystore -storepass 111111111 < data.txt 

    See also SO: Forcing the use of english in JDK7 tools 另请参阅SO:强制在JDK7工具中使用英语

  2. To change Java language globally, set the JAVA_TOOL_OPTIONS environment variable to have the -Duser.language=en value. 要全局更改Java语言,请将JAVA_TOOL_OPTIONS环境变量设置为具有-Duser.language=en值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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