题
i use ghost4j in an java webapplication. This lib loads a dll through JNA. now i want to place the dlls in the classpath, because the working dir of this application changes when i run a test, run it on server with eclipse, or just run a main function for testing purposes.
How can i tell JNA to look in the classpath?
i thought on something like
class.getProtectionDomain().getCodeSource().getLocation().getPath()
but how can i add this programatical to the searchpath? i don't like to add VM arguments
解决方案
JNA will look in jna.library.path
for native libraries, falling back to system defaults (usually the same as java.library.path
) if nothing is found there.
System.setProperty("jna.library.path", "/whatever/path/you/want");
不隶属于 StackOverflow