Trash Can
Trash Can

Reputation: 6814

java.lang.UnsatisfiedLinkError even though LD_LIBRARY_PATH and -Djava.library.path were set

OS is Linux Ubuntu 16.04 LTS

(The application runs absolutely fine on Windows, I did not have to configure anything after the installation of Matlab Compiler SDK)

I am writing a web application in Java which also calls some functions written in Matlab which requires install Matlab Compiler SDK, after the installation, it told me to append this /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64: to the end of the LD_LIBRARY_PATH variable, which I did by

export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64:

But why do I keep getting this error when I try to run the web app in Netbeans?

java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.0.1 on java.library.path.
This library is typically installed along with MATLAB or the MCR. Its absence may indicate an issue with that installation or the current path configuration.

libmwmclmcrrt.so.9.0.1 resides inside the /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64 directory

I also added -Djava.library.path to point to 3 directory entries above to see if it helps, but it does not do anything good at all.

I read several posts on here, but did not seem to solve it.

  1. JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)
  2. java.lang.UnsatisfiedLinkError even on setting -Djava.library.path

How do I fix this? BTW, this is a web application

Upvotes: 3

Views: 1477

Answers (1)

Trash Can
Trash Can

Reputation: 6814

[ Tested on Mac OS High Sierra version 10.13.5 (17F77), should be similar for Linux ]

What I did was when I started the application server (In my case Payara). I provided the path to the javabuilder.jar like so

For Payara Full

asadmin deploy --libraries /path/to/javabuilder.jar app.war

For Payara Micro

java -jar payara-micro.jar --deploy app.war --addlibs /path/to/javabuilder.jar

Note: /path/to/javabuilder.jar is the location of javabuilder.jar within the directory MATLAB_HOME/MATLAB_Runtime/SOME_VERSION/toolbox/javabuilder/jar/javabuilder.jar, Copying this javabuilder.jar file out and reference it will fail with the same error. It must be its original path for it to work. Not sure why

Upvotes: 1

Related Questions