[英]How to add a jar to the boot classpath in java 9
In my application that runs on java 8, I am using -bootclasspath:p
to add a jar to the boot classpath.在我在 java 8 上运行的应用程序中,我使用-bootclasspath:p
将一个 jar 添加到引导类路径。 In java 9, the option is removed.在 java 9 中,该选项被删除。 What is the alternative to do the same in java 9?在 java 9 中执行相同操作的替代方法是什么?
You may use -Xbootclasspath/a
.您可以使用-Xbootclasspath/a
。 Please refer to the release notes which states:-请参阅发行说明,其中指出:-
The boot class path has been mostly removed in this release.在此版本中,引导类路径大部分已被删除。 The java
-Xbootclasspath
and-Xbootclasspath/p
options have been removed. java-Xbootclasspath
和-Xbootclasspath/p
选项已被删除。The
javac -bootclaspath
option can only be used when compiling to JDK 8 or older.javac -bootclaspath
选项只能在编译到 JDK 8 或更早版本时使用。 The system propertysun.boot.class.path
has been removed.系统属性sun.boot.class.path
已被删除。Deployments that rely on overriding platform classes for testing purposes with
-Xbootclasspath/p
will need to changed to use the--patch-module
option that is documented in JEP 261 .依赖覆盖平台类进行测试的部署-Xbootclasspath/p
需要更改为使用JEP 261 中记录的--patch-module
选项。The
-Xbootclasspath/a
option is unchanged.-Xbootclasspath/a
选项保持不变。
-bootclasspath:p
add classes from jar to the begin of default bootstrap class path (prepended). -bootclasspath:p
将 jar 中的类添加到默认引导类路径的开头(前置)。 It isn't longer supported in JVM 9 or greater. JVM 9 或更高版本不再支持它。
-bootclasspath:a
add classes from jar to the end of default bootstrap class path (appended). -bootclasspath:a
将 jar 中的类添加到默认引导类路径(附加)的末尾。 This option is supported in JVM 9 or greater. JVM 9 或更高版本支持此选项。 https://docs.oracle.com/cd/E15289_01/JRCLR/optionx.htm#i1021218 https://docs.oracle.com/cd/E15289_01/JRCLR/optionx.htm#i1021218
In my case when I declare variables in this order:就我而言,当我按以下顺序声明变量时:
JAVA_OPTS="$SOME_OPT" JAVA_OPTS="$SOME_OPT"
JAVA_OPTS="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS" JAVA_OPTS="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS"
I catch classNotFoundException.我抓住了 classNotFoundException。 And when I reverse order:当我颠倒顺序时:
JAVA_OPTS="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS" JAVA_OPTS="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS"
JAVA_OPTS="$SOME_OPT" JAVA_OPTS="$SOME_OPT"
ClassNotFound exception disappear. ClassNotFound 异常消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.