0

I have a java project with a user library that can be read from the IDE at runtime without any problem. When I export the project to an executable jar, the program no longer finds the library. Specifically,

try {
        System.loadLibrary("DPJava64");

    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
    }

The program runs fine from the IDE, but I get the error message when I try to run the executable jar. The executable jar says that it expects an absolute path.

user2303321
  • 297
  • 2
  • 11
  • A library contained in a JAR cannot be loaded. Either having it outside the JAR or having some Java code that extract it first and then load it from the location where it was extracted. – howlger Jan 31 '20 at 09:16

1 Answers1

0

you need to pass library as classpath parameter using -cp parameter, alternatively if you are using maven you can build uber jar

Including all the jars in a directory within the Java classpath

Vinay Lodha
  • 2,185
  • 20
  • 29