In my application that runs on java 8, I am using -bootclasspath:p to add a jar to the boot classpath. In java 9, the option is removed. What is the alternative to do the same in java 9?
How to add a jar to the boot classpath in java 9
8.8k Views Asked by Qwerty At
2
There are 2 best solutions below
0
On
-bootclasspath:p add classes from jar to the begin of default bootstrap class path (prepended). It isn't longer supported in JVM 9 or greater.
-bootclasspath:a add classes from jar to the end of default bootstrap class path (appended). This option is supported in JVM 9 or greater.
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="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS"
I catch classNotFoundException. And when I reverse order:
JAVA_OPTS="-javaagent:../agent.jar -Xbootclasspath/a:../agent-boot.jar $JAVA_OPTS"
JAVA_OPTS="$SOME_OPT"
ClassNotFound exception disappear.
You may use
-Xbootclasspath/a. Please refer to the release notes which states:-