I have been trying to load jpostal into an existing maven project. To do this, I added a jpostal folder with the following files at the root directory of my project:
libjpostal_expander.a
libjpostal_expander.jnilib
libjpostal_expander.la
libjpostal_parser.a
libjpostal_parser.jnilib
libjpostal_parser.la
This is my main class:
public class Main {
public static void main(String[] args) {
System.loadLibrary("jpostal_parser");
}
}
Before running my class, I set -Djava.library.path=./jpostal.
This is the output:
/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/bin/java -Djava.library.path=./jpostal -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=56917:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/areeb.siddiqui/Documents/Projects/jpostalLibTest/target/classes Main
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpostal_parser in java.library.path: [./jpostal]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2662)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:827)
at java.base/java.lang.System.loadLibrary(System.java:1871)
at Main.main(Main.java:3)
Process finished with exit code 1
Compute Details:
Chip: MacBook Pro (M1 Pro chip)
OS: macOS Monterey (v12.1)
Things already tried:
Copy jpostal files into another project and try and load it there. Doesn't work.
I tried using System.load() instead of loadLibrary by giving it the absolute path of the libjpostal_parser.jnilib. It gave me an error that it can not find the file.
I tried playing with changing the working directory and java.library.path to reference the library in other ways. Didn't work.
Clone jpostal locally and build it on my computer then copy the resulting src/main/jniLibs content into /jpostal in my project.
Building it was a bit tricky. I had to comment out AX_JNI_INCLUDE_DIR in configure.ac because it kept trying to find JDK header in locations where it isnt as I have installed oracle jdk and the macro fails to look inside /Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/include. Then removed the loop that was creating CFLAGS variable and replace that with the following lines:
I have been trying to load
jpostal
into an existing maven project. To do this, I added ajpostal
folder with the following files at the root directory of my project:This is my main class:
Before running my class, I set
-Djava.library.path=./jpostal
.This is the output:
Compute Details: Chip: MacBook Pro (M1 Pro chip) OS: macOS Monterey (v12.1)
Things already tried:
libjpostal_parser.jnilib
. It gave me an error that it can not find the file.java.library.path
to reference the library in other ways. Didn't work.src/main/jniLibs
content into/jpostal
in my project. Building it was a bit tricky. I had to comment outAX_JNI_INCLUDE_DIR
inconfigure.ac
because it kept trying to find JDK header in locations where it isnt as I have installed oracle jdk and the macro fails to look inside/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/include
. Then removed the loop that was creatingCFLAGS
variable and replace that with the following lines:Didn't work.
I am out of ideas on what could possibly be wrong. How to fix this?