Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no jpostal_parser in java.library.path #41

Open
mareebsiddiqui opened this issue Jul 7, 2022 · 0 comments
Open

no jpostal_parser in java.library.path #41

mareebsiddiqui opened this issue Jul 7, 2022 · 0 comments

Comments

@mareebsiddiqui
Copy link

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:

  1. libjpostal_expander.a
  2. libjpostal_expander.jnilib
  3. libjpostal_expander.la
  4. libjpostal_parser.a
  5. libjpostal_parser.jnilib
  6. 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:

  1. Copy jpostal files into another project and try and load it there. Doesn't work.
  2. 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.
  3. I tried playing with changing the working directory and java.library.path to reference the library in other ways. Didn't work.
  4. 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:
CFLAGS="-I/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/include"
CFLAGS="$CFLAGS -I/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home/include/darwin"

Didn't work.

I am out of ideas on what could possibly be wrong. How to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant