0
votes

I am working on a java project, need to call the methods from the native .dylib file.

I am providing the absolute path to load the file before it loads I get the error. Here is my code to load the dylib file.

package jna.introduction;

public class MyFirstJNAProgram {

    public static void main(String args[]) {
        CRuntimeLibrary.INSTANCE.printf("Hello World from JNA !");
        System.out.println(System.getProperty("os.name"));
        
        System.out.println("Loading Dylib file");
        System.load("/Users/startelelogic/Desktop/Anil2/JNA/src/main/java/jna/introduction/libapp-plugin.dylib");
        System.out.println("Loading Dylib file");
    }
}

When I am trying to load the .dylib file in my program getting the

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/startelelogic/Desktop/Dylib_File/libapp-plugin.dylib: dlopen(/Users/startelelogic/Desktop/Dylib_File/libapp-plugin.dylib, 1): Library not loaded: @rpath/linphone++.framework/Versions/A/linphone++
  Referenced from: /Users/startelelogic/Desktop/Dylib_File/libapp-plugin.dylib
  Reason: image not found
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
    at java.lang.Runtime.load0(Runtime.java:810)
    at java.lang.System.load(System.java:1086)
    at jnatest_nonmaven.JNATEST_NonMaven.main(JNATEST_NonMaven.java:22)
/Users/startelelogic/Library/Caches/NetBeans/11.3/executor-snippets/run.xml:111: The following error occurred while executing this line:
/Users/startelelogic/Library/Caches/NetBeans/11.3/executor-snippets/run.xml:94: Java returned: 1
BUILD FAILED (total time: 0 seconds)

I am trying to load basic, but it did not worked.

Few link which I have already visited but it did not solve my problem.

load java native file lib

How to use dylib file?

How to set the java.library.path from Eclipse

How do I set the classpath in NetBeans?

Any help will appreciated.

Does this answer your question? dyld: Library not loaded: ..... How to correctly tell GCC Compiler where to find another static library? (Different language & environment, same issue) - Siguza
Thanks @Siguza look similar, will check. - Rishita Shah
I have gone through this, It did not helped me. - Rishita Shah
Alright, then could you please post the output of running otool -l against both libapp-plugin.dylib and linphone++? - Siguza