How to add a jar to the boot classpath in java 11

我是研究僧i 提交于 2021-02-06 14:28:29

问题


In my application which is running on Java 8 I used third party library which is using org.jboss.logmanager.LogManager So I added this jar in bootclass path and it works fine. But when migrate to java 11 either -Xbootclasspath/a or -Xbootclasspath/p is not working and I can not start my application.

set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/a:D:/wildfly-10.1.0.Final/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.0.4.Final.jar

I found How to add a jar to the boot classpath in java 9 answer. But it is not working for java 10 or 11. Can anyone please help me?


回答1:


I tried the following:

(1) For me replacing -Xbootclasspath/p with -Xbootclasspath/a - Did not work

(2) Then I tried to remove the whole line as this has been suggested by others -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p: <path_to_jboss_logmanager>/jboss-logmanager-<version>.jar - Did not work

(3) Then I also removed the logmanager from -Djboss.modules.system.pkgs=org.jboss.logmanager" and then it worked!

So only the combination of 2+3 finally worked.




回答2:


In JAVA jdk 11 and above, if you are developing a java console app then you only need to set the PATH environment variable. You do not need to set the CLASSPATH environment variable.



来源:https://stackoverflow.com/questions/53529593/how-to-add-a-jar-to-the-boot-classpath-in-java-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!