How to make the target library available for my Java application?

Using JNA, the documentation says:

Make your target library available for your Java program. There are two ways to do this: the preferred method is to set the system property jna.library.path to the path to your target library. This property is similar to java.library.path , but applies only to libraries loaded by JNA.

What does it mean? How to set the system property jna.library.path ? My application should reference Kernel32.dll

thanks

+4
source share
1 answer

You can set the system properties using the -D option when invoking the Java virtual machine at the command line:

java -Djna.library.path=<path to your library> MainClass

You can also set this programmatically in your code when starting your applications when it was read, for example. configuration file:

 System.setProperty("jna.library.path", <path to your library>); 

I have not used JNA myself, so I don’t know if it is too late for the JVM when you set the value in the code. In this case, go to the first option.

+9
source

Source: https://habr.com/ru/post/1302975/


All Articles