Sunday, 15 September 2013

java - Dll calling another dll with JNA -



java - Dll calling another dll with JNA -

let me seek explain problem..

i have next directory structure:

main dir src ext bin

today dlls within folder "bin" , working fine, due requirement, need alter "ext" folder.

on application's startup, setting jna.library.path , java.library.path in runtime:

// jna system.setproperty("jna.library.path", mylibrarypath);

and

// java final field usrpathsfield = classloader.class.getdeclaredfield("usr_paths"); usrpathsfield.setaccessible(true); final string[] paths = (string[])usrpathsfield.get(null); for(string path : paths) { if(path.equals(librarypath)) { return; } } final string[] newpaths = arrays.copyof(paths, paths.length + 1); newpaths[newpaths.length-1] = librarypath; usrpathsfield.set(null, newpaths);

the code above sets java.library.path after initialization.

i tried run on line command well:

-djna.library.path=path_to_ext -djava.library.path=path_to_ext

so, in tests detected problem occurs when phone call method dll, , method, calls other method of dll.

can help me?

thanks lot

i solve question setting environment variable hkey_current_user/environment/path mylibrarypath.

java dll jni jna

No comments:

Post a Comment