Managing DLL dependencies with Maven

Go To


I have a Java program with Maven managing its dependencies. One of those dependency is a JNI wrapper for another program. Maven takes care of the reference to the relevant JAR file, but I'm left messing around with the DLL file myself.

Is there a good way of having Maven handle the DLL as well? Ideally I would like to have the DLL loaded into our local repository like the JAR file.

2009-06-16 14:15
by Kris


Did you try something like this:


You can add them to maven's repository with something like this:

mvn install:install-file -Dfile=footron.dll -DartifactId=footron  -Dversion=4.2 -Dpackaging=dll -DgeneratePom=true 

Haven't done this for DLLs but something like this should work.

2009-06-19 21:26
by sal
Actually, after spending some additional time thinking about it I decided it was worth investing in the effort to remove the need for the DLL via JNI. Probably worth the effort in the long run. I will look into your suggestion though out of curiosity - Kris 2009-06-20 14:07
@Kris, that's probably a good idea. I thought of suggesting that but I don't make it a habit of telling people to fix code I haven't seen. AKA, Psychic code revie - sal 2009-06-23 15:32
@sal, so does having maven manage the .dll file automatically call System.loadLibrary()? Or do you still have to call System.loadLibrary()? I'm just wondering how I make sure that dll is loaded for other objects to use - j will 2015-01-22 23:19
I doubt it calls anything for you. The dll will be on the class path, but that's about it - sal 2015-01-26 02:34
I'm unsure how -Dpackaging=dll can work, but it does. When I try and make a real pom and use it it doesn't work however - ggb667 2017-03-07 19:30


I found another solution, which is described in the answer to this question: Using maven with DLL from third party and managing the name of the DLL

Basically, if you put the DLL into a ZIP file, and manage it as a separate dependency, and use the nativedependencies-maven-plugin, then the DLL will get unpacked with the right name.

2018-05-22 21:03
by Irv