首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在启动jshell时将JVM选项传递给jshell

如何在启动jshell时将JVM选项传递给jshell
EN

Stack Overflow用户
提问于 2018-12-21 23:55:45
回答 2查看 1.1K关注 0票数 6

我想做以下几点:

jshell -v -Duser.country=FR -Duser.language=fr

这样就得到了一个个性化的Locale.getDefault()

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-12-22 05:18:20

代码语言:javascript
复制
$ jshell -R -Dtest1=one
|  Welcome to JShell -- Version 11.0.1
|  For an introduction type: /help intro

jshell> System.getProperty("test1")
$1 ==> "one"

它被记录在帮助选项中

代码语言:javascript
复制
$ 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
票数 3
EN

Stack Overflow用户

发布于 2018-12-22 02:15:00

这样做的一种可能方法是使用一个setLocale.jsh,其中脚本的内容是:

代码语言:javascript
复制
java.util.Locale.setDefault(java.util.Locale.CANADA) // set your locale

然后,您还可以在jshell命令行上使用

代码语言:javascript
复制
/set start <path to setLocale.jst>

并确保重置状态以应用更改。

代码语言:javascript
复制
/reset

要验证Locale中的更改,可以执行以下操作

代码语言:javascript
复制
java.util.Locale.getDefault()   // prints en_CA

请注意,上面的内容仅意味着jshell的当前会话。可以使用-retain选项保留设置,因此如果您使用

代码语言:javascript
复制
/set start -retain

然后,set启动脚本也将加载到jshell工具的下一次调用中。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53892000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档