0

I am trying to load a dll native library using System.load method, but it doesn't help, it throws exception.

Here is code:

package test;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import one.xmpp.server.network.BigResponseServer;

public class main {
    static {
        System.load("D:\\one-xmpp-proxy-master\\one-xmpp-proxy-master\\libs\\tcnative-1.dll");
    }

    public static void main(String [] args) {
        Runtime.getRuntime().loadLibrary("tcnative-1.dll");     
    }
}

The program throws this exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no tcnative-1.dll in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.Runtime.loadLibrary(Unknown Source)
    at test.main.main(main.java:26)
Samuel Philipp
  • 10,631
  • 12
  • 36
  • 56

1 Answers1

0

In order for System.loadLibrary() to work, the library (on Windows, a DLL) must be in a directory somewhere on your PATH or on a path listed in the java.library.path system property (so you can launch Java like java -Djava.library.path=/path/to/dir).

Read this answer for full explanation, make sure to upvote the author.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111