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

标签 java java-9 jvm-arguments jshell

我想做以下事情:

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

关于java - 如何在启动时将 JVM 选项传递给 jshell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53892000/

相关文章:

java - Scala Function1<T,U> 在 Java 中变为 Function1<Object,Object>

java - 在 java 应用程序中禁用 jaspersoft 日志记录

Java 9.0 |类加载器::getResourceAsStream: NullPointerException

Java 堆/池大小

java - JBoss 流口水的推荐设置

java - 为什么此 PrintWriter 不填充此文件?

java - com.mongodb.MongoTimeoutException : Timed out after 10000 ms while waiting to connect

java - 如何使 javadoc 文档在 JShell 中可用?

Java 9 嵌套(分层或父/子)模块

java - 为什么 System.getProperties() 对 -D 定义的属性返回 null?