Я хочу сделать следующее:
jshell -v -Duser.country=FR -Duser.language=fr
Чтобы получить, например, персонализированный Locale.getDefault()
.
Я хочу сделать следующее:
jshell -v -Duser.country=FR -Duser.language=fr
Чтобы получить, например, персонализированный Locale.getDefault()
.
$ jshell -R -Dtest1=one
| Welcome to JShell -- Version 11.0.1
| For an introduction type: /help intro
jshell> System.getProperty("test1")
$1 ==> "one"
Это задокументировано в параметрах справки
$ jshell -h
Usage: jshell <option>... <load-file>...
where possible options include:
--class-path <path> Specify where to find user class files
--module-path <path> Specify where to find application modules
--add-modules <module>(,<module>)*
Specify modules to resolve, or all modules on the
module path if <module> is ALL-MODULE-PATHs
--enable-preview Allow code to depend on preview features of this release
--startup <file> One run replacement for the startup definitions
--no-startup Do not run the startup definitions
--feedback <mode> Specify the initial feedback mode. The mode may be
predefined (silent, concise, normal, or verbose) or
previously user-defined
-q Quiet feedback. Same as: --feedback concise
-s Really quiet feedback. Same as: --feedback silent
-v Verbose feedback. Same as: --feedback verbose
-J<flag> Pass <flag> directly to the runtime system.
Use one -J for each runtime flag or flag argument
-R<flag> Pass <flag> to the remote runtime system.
Use one -R for each remote flag or flag argument
-C<flag> Pass <flag> to the compiler.
Use one -C for each compiler flag or flag argument
--version Print version information and exit
--show-version Print version information and continue
--help, -?, -h Print this synopsis of standard options and exit
--help-extra, -X Print help on non-standard options and exit
Одним из возможных способов сделать это может быть использование сценарий запуска например. setLocale.jsh
где содержание скрипта будет:
java.util.Locale.setDefault(java.util.Locale.CANADA) // set your locale
затем вы можете использовать в командной строке jshell
/set start <path to setLocale.jst>
и убедитесь, что сброс состояния для применения изменения
/reset
чтобы проверить изменение в Locale
, вы можете сделать
java.util.Locale.getDefault() // prints en_CA
Обратите внимание, вышеизложенное относится только к текущему сеансу jshell
. Параметр можно сохранить с помощью опции -retain
, поэтому, если вы используете
/set start -retain
тогда установленный сценарий запуска будет загружен при следующем вызове инструмента jshell
.