javapackager - partially self-contained apps in JDK 9

Scott Palmer swpalmer at
Tue Apr 25 17:55:48 UTC 2017

> On Apr 11, 2017, at 1:43 PM, Alan Snyder <javalists at> wrote:
> I have run into a problem in moving my macOS apps from JDK 8 to 9. The issue relates to using MySQL via JDBC.
> The connector class name is fixed. The class is loaded using Class.forName(). However, there can be different versions
> of the connector in different JAR files, and the proper version might need to be synced with the currently installed version
> of MySQL.
> In JDK 8, I used the extension mechanism to load the MySQL connector JAR rather than building this JAR into the bundled app.
> My thinking was that the connector might need to be updated in sync with the database and I should not have to rebuild apps to do that.
> In JDK 9, the extension mechanism is gone. I have not found any way to achieve the equivalent effect. It seems that javapackager
> controls the setting of the CLASSPATH. I have not found an option that would allow me to extend the CLASSPATH with a directory
> where the connector JAR could be found. Is there a way to do this?

My application ran into classpath issues because it tried to dynamically add plugins to the classpath and that broke on Java 9.  To work around it I created an agent so I could get access to the java.lang.Instrumentation interface to add to the classpath.  You might try that approach.  It’s ugly, but better than reflectively accessing private fields of URLClassLoader, which doesn’t work for Java 9 :-)


More information about the openjfx-dev mailing list