Include additional files to the DLL with JNA

Asked

Viewed 146 times

0

am having a problem running a DLL in Java via JNA, the DLL searches for a file that is in the same folder called "propriedades.properties", this DLL works normally, but when using JNA it does not find the file. It turns out the JNA runs the DLL elsewhere, not in its source folder ("This is just an assumption on my part"). The code I use is below:

System.setProperty("jna.library.path", "C:\\");
        System.setProperty("jna.debug_load", "true");
        System.setProperty("jna.debug_load.jna", "true");

DllMicros micros = (DllMicros) Native.loadLibrary("dllmicros", DllMicros.class);

micros.CallSat(_Id, _ConfigVenda, _DadosVendas, _Error);

I activated the debug to try to identify the problem, but it does not give any indication, since the DLL is included normally, anyway I will include it too.

Looking in C:\jnidispatch.dll
Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader@e2f2a for /com/sun/jna/win32-x86/jnidispatch.dll
Found library resource at jar:file:/E:/Desenvolvimento/Workspaces/trunk4.4/dll-test/lib/jna-4.2.1.jar!/com/sun/jna/win32-x86/jnidispatch.dll
Trying C:\Users\Ricardo\AppData\Local\Temp\jna--1433617560\jna2182820279403986556.dll
Found jnidispatch at C:\Users\Ricardo\AppData\Local\Temp\jna--1433617560\jna2182820279403986556.dll
Looking for library 'dllmicros'
Adding paths from jna.library.path: C:\
Trying C:\dllmicros.dll
Found library 'dllmicros' at C:\dllmicros.dll
Ocorreu um erro: O arquivo de propriedades n�o p�de ser carregado! // Este erro é lançado pela DLL que não encontra o arquivo na pasta em que está sendo executada

If anyone has any tips, I’d appreciate it.

1 answer

1


I’ve gone through all the documentation on JNA and there really is the possibility to attach a file to the execution of DLL, the solution I found was to create methods in the DLL to assign the path of the properties file and thus not be dependent on having both in the same folder while running.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.