Packaging JNI Library within Docker

--

For example, your Java application myapp depends on xyz JNI library.

Download and package the xyz JNI library within your application as shown below.

myapp/lib/xyz/ :
linux

myapp/pom.xml :
<dependency>
<groupId>com.apollo.xyz</groupId>
<artifactId>com-apollo-xyz</artifactId>
<version>1.0</version>
</dependency>

mvn clean package

myapp/Dockerfile:
FROM docker/openjdk:17
ENV LD_LIBRARY_PATH=/xyz
COPY target/myapp.jar /
COPY myapp/lib/xyz/linux/*.* /xyz/
CMD java $JAVA_OPTS -Djava.library.path=”/xyz” -jar /myapp.jar

I wish you success in loading the jni library without getting the dreaded java.lang.UnsatisfiedLinkError.

--

--

Apollo Software Labs
Apollo Software Labs

Written by Apollo Software Labs

Hands-on Solution Architect passionate about building secure, scalable, and high performance solutions in the cloud.

No responses yet