Include additional files for the DLL with JNA

0

I'm having a problem running a DLL in Java via JNA, the DLL looks for a file that is in the same folder named "propriedades.properties" , this DLL works normally, but when using JNA it does not find the file. It seems that JNA runs the DLL somewhere else, not in its source folder ("That's just a guess on my part"). The code I use is as follows:

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 clue, since the DLL is included normally, anyway I will include it as well.

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'm grateful.

    
asked by anonymous 13.11.2015 / 20:35

1 answer

1

I analyzed all the JNA documentation and there really is not the possibility of attaching a file to the DLL execution, the solution I found was to create methods in the DLL to assign the properties file path and so do not get dependent on having both in the same folder during execution.

    
16.11.2015 / 14:02