Okay, I’m working on a Java project using nar-maven-plugin to build a native library in another module then I’m using maven to copy that NAR file over to the module I’d like to use it in via JNA. I’ve managed to get this far:
target module layout showing NAR file locations
The nar file is being copied to the Jar file, I’ve gone into the local repo, extracted it and seen the file myself. I’m using JNA to extract and load the library like so:
try {
File lib = Native.extractFromResourcePath("target/test-classes/gamelibrary-1.0-SNAPSHOT-amd64-Windows-gpp-shared.nar");
Native.load(lib.getPath(), GameLib.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
However, my test that tries to load the library is failing:
java.lang.ExceptionInInitializerError at com.rainbowsix.warehousequest.game.GameLibraryTest.setup(GameLibraryTest.java:42)
Caused by: java.lang.RuntimeException: java.io.IOException: Native library (win32-x86-64/target/test-classes/gamelibrary-1.0-SNAPSHOT-amd64-Windows-gpp-shared.nar.dll) not found in resource path (C:UsersE40070846DocumentsDev2warehouse-questgametargettest-classes;
at com.rainbowsix.warehousequest.game.GameLibraryTest.setup(GameLibraryTest.java:42)
What am I doing wrong?
I’ve tried putting the library in several different places but alas, no luck, same error no matter where I stick it.
Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.