你如何替换 Java 9 中的背书目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46419496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you replace endorsed directory in Java 9?
提问by keiki
In Java 8 and prior there exists the mechanism to use an endorsed directory(java.endorsed.dirs), which is a collection of libraries which overrides JDK internal implementations.
在 Java 8 及更早版本中,存在使用认可目录 (java.endorsed.dirs) 的机制,该目录是覆盖 JDK 内部实现的库集合。
How can I solve this in Java-9? As endorsed dirs where removed there?
我如何在 Java-9 中解决这个问题?作为背书的目录在哪里删除?
采纳答案by Naman
In JDK 9, you can use upgradeable modulesor put the JAR files on the classpath.
在 JDK 9 中,您可以使用可升级模块或将JAR 文件放在类路径中。
The Java 9 migration guidestates:
在Java的9迁移指南规定:
The
java.endorsed.dirs
system property and thelib/endorsed
directory are no longer present. Thejavac
compiler andjava
launcher will exit if either one is detected.
该
java.endorsed.dirs
系统属性和lib/endorsed
目录不再存在。 如果检测到任何一个,javac
编译器和java
启动器将退出。
You would end up finding the error if any of these exists as :
如果其中任何一个存在,您最终会发现错误:
<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs in modular form will be supported via the concept of upgradeable modules. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs in modular form will be supported via the concept of upgradeable modules. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
These endorsed-standards override mechanism was removed to attain Modular Run-Time Imagesand would now use the modular image.
这些认可的标准覆盖机制被删除以获得模块化运行时映像,现在将使用模块化映像。
A modular image is composed of modules rather than JAR files. Going forward, endorsed standards and standalone APIs are supported in modular form only, via the concept of upgradeable modules.
模块化映像由模块而不是 JAR 文件组成。展望未来,通过可升级模块的概念,仅以模块化形式支持认可的标准和独立 API 。
回答by timothy mickol
This is a specific solution but can probably be generalized. On System Version: macOS 10.14.6 (18G3020) Kernel Version: Darwin 18.7.0 I have OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) and java_ee_sdk-8u1 installed.
这是一个特定的解决方案,但可能可以推广。系统版本:macOS 10.14.6 (18G3020) 内核版本:Darwin 18.7.0 我安装了 OpenJDK 64 位服务器 VM(构建 13.0.2+8,混合模式,共享)和 java_ee_sdk-8u1。
I encountered this error when executing xjc:
我在执行 xjc 时遇到了这个错误:
[foo@bar bin 14:47:27] sudo ./xjc
-Djava.endorsed.dirs=./../modules/endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.enter code here
I edited the last line in ~/glassfish5/glassfish/bin/xjc
to remove the -Djava.endorsed.dirs
bit:
BEFORE
我编辑了最后一行~/glassfish5/glassfish/bin/xjc
以删除该-Djava.endorsed.dirs
位:BEFORE
exec "$JAVA" -Djava.endorsed.dirs="$AS_INSTALL_LIB/endorsed" -cp "$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/javax.xml.rpc-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar" com.sun.tools.xjc.Driver "$@"
AFTER
后
exec "$JAVA" -cp "$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/javax.xml.rpc-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar" com.sun.tools.xjc.Driver "$@"
After which ~/glassfish5/glassfish/bin/xjc
worked as expected
之后~/glassfish5/glassfish/bin/xjc
按预期工作
回答by Vamsi Veginati
I also faced same issue, Java versions higher than 8 are not supported by Tomcat 9.
please check bin/catalina.sh for more information.
#JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
#containing some jars in order to allow replacement of APIs
#created outside of the JCP (i.e. DOM and SAX from W3C).
#It can also be used to update the XML parser implementation.
#This is only supported for Java <= 8.
#Defaults to $CATALINA_HOME/endorsed.