I have a dll (let's name it Sample.dll) that is being called by a Java application thru JNA. The said dll locates a file inside a folder named "Data". I think the said dll was loaded successfully since there was no error message being returned. Below is the code to load the dll:
sampleLibrary = (SampleLibrary)Native.loadLibrary("Sample", SampleLibrary.class);
After execution of that code, a native method is called to open a session. This method accepts the path of a folder as a parameter.
sampleLibrary.openSession(path);
The JNA cannot seem to locate the file since the error is being returned that says the file does not exist. I try to set and print the "user.dir" and the "java.library.path" to see if the path being passed is correct.
System.setProperty("java.library.path", "C:/Sample");
System.out.println("user.dir property: " + System.getProperty("user.dir"));
System.out.println("java.library.path property: " + System.getProperty("java.library.path"));
These return the working directory where the jar, dll and a Data folder are located.
File Structure:
C:\Sample
\-- SampleJna.jar
\-- Sample.dll
\-- Data
\----- some files