I am working on a Java GUI application that uses MATLAB code for calculations. However, the MATLAB code itself uses a DLL file. I packed all my MATLAB functions into a class and created a jar file.
I added the C header file and DLL file in the project root folder of the Java project and added the jar containing MATLAB code to properties. However, when I call the methods, it seems to execute, but its unable to load the DLL file.
Here is the error message I get:
{??? Error using ==> loadlibrary at 477
There was an error loading the library
**"C:\Users\AUG\Documents\Backup\SourceTracing\epanet2.dll"**
FAiled..Error using ==> loadlibrary at 477
Undefined function or variable 'epanet2_proto'.
There was an error loading the library
"C:\Users\AUG\Documents\Backup\SourceTracing\epanet2.dll"
Error in ==> epanetloadfile at 31
Undefined function or variable 'epanet2_proto'.
Error in ==> sourceTraceGUI at 8
when I actually checked the address, the DLL file is there along with the header file as well in that directory.
Update
I tried all of Richie's suggestions.
I could run the method that uses DLL on MATLAB.
I could call any normal method from Java that doesn't use the DLL.
I could even call the method that uses the DLL, but the problem is occurring when the library is supposed to load.
It says
Error using ==> loadlibrary at 477
There was an error loading the library
"C:\Users\AUG\Documents\Backup\SourceTracing\epanet2.dll"
If I run the code in MATLAB though, it all works fine. It is just when I run from Java, the DLL doesn't load.
I posted this question in the Matlab forum and finally got some answers. For those who have the same problem in future, refer to this link.
http://www.mathworks.com/matlabcentral/answers/11321-loading-a-dll-in-mathlab-through-java