It is easy to add a jar file to the java classpath by using the command
java -cp path/to/jar myjar.jar

The problem with this approach is that the “-cp” or “-classpath” command will overwrite your default classpath, meaning that you will loose all of the other references that existed in there before, you only have the jars that you reference within the classpath command parameter.

In my case, i wanted to APPEND multiple jars during container startup so they can be referenced by my products plug-ins, so i had to figure out how to open up my jar to enable this , after that, it was very easy to append jars.
In the extracted jar directory structure, you will find that you have a “BOOT-INF\lib” directory.

Any of the lib directories contents are automatically added to the classpath when the program is run.

So we want to create another directory inside the lib directory called “external_lib”


This folder can now be mounted in a docker compose or run command, the folder in the host filesystem can contain any additional jar files that you want to append to the classpath.

Example compose:

image: mybaseimage:1.0
- .\host\tomount\lib:C:\app\BOOT-INF\lib\external_lib


Mounting BOOT-INF\classes\lib will not work!