在Java 8和之前的版本中,存在使用支持目录(java.endorsed.dirs)的机制,该目录是覆盖JDK内部实现的库的集合。
如何在Java-9中解决这个问题?被认可的dirs在那里被删除?
答案 0 :(得分:10)
在JDK 9中,您可以使用upgradeable modules或将 JAR文件放在类路径上。
java.endorsed.dirs
系统属性和lib/endorsed
目录不再存在。javac
编译器和java
如果检测到任何一个,启动器将退出。
如果其中任何一个存在,您最终会发现错误:
<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.
这些已通过标准的覆盖机制被删除以获得Modular Run-Time Images,现在将使用模块化图像。
模块化图像由模块而不是JAR文件组成。展望 支持转发,认可标准和独立API 只有模块化形式,通过upgradeable modules的概念。
答案 1 :(得分:1)
这是一个特定的解决方案,但可能可以一概而论。在系统版本上:macOS 10.14.6(18G3020)内核版本:Darwin 18.7.0我安装了OpenJDK 64位服务器VM(内部版本13.0.2 + 8,混合模式,共享)和java_ee_sdk-8u1。
我在执行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
我编辑了~/glassfish5/glassfish/bin/xjc
的最后一行以删除-Djava.endorsed.dirs
位:
之前
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 "$@"
之后
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 "$@"
之后~/glassfish5/glassfish/bin/xjc
正常工作
答案 2 :(得分:0)
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.