- Did you correctly install the Java Runtime Environment? Here more details for apple silicon: https://www.mathworks.com/support/requirements/apple-silicon.html
- The library might be blocked by your antivirus, maybe you need to whitelist it in your security software
I get an error message while using a JAR that is compiled by Library Compiler
4 views (last 30 days)
Show older comments
I have a MATLAB project, which I compile using the MATLAB compiler to a JAR file and call from a Java project. I have been using the compiled file on Windows without any issues for a few years. Recently, I switched to Mac. Today, I decided to compile my Java project on Mac OS Sequoia. I compiled the MATLAB code on my Mac Studio with M2 Max processor and added to my Java project as a library as usual. However, I get the following error when I try to plot a graph using it:
java.lang.UnsatisfiedLinkError: Can't load library: /System/Library/Frameworks/gluegen-rt.Framework/gluegen-rt
I couldn't resolve the problem despite spending several hours on it. Could you help me with this problem?
0 Comments
Accepted Answer
Mathias
on 6 Mar 2025
Edited: Mathias
on 6 Mar 2025
Hi Cagri,
For some reason the "gluegen-rt.jar" library cannot be loaded, as the error states. This library should be found here: <matlabroot>\java\jarext\gluegen-rt.jar where 'matlabroot' is the directory you get after running >>matlabroot in MATLAB.
Here a few ideas:
Since this is a graphics-related issue, you might also want to try turning off 'OpenGL'. This will probably result in lesser graphics performance, but it might get your jar running again. To do so, when compiling your jar, set the -noopengl flag. How to set a flag when compiling is detailed here:
Alternatively, in your Java code, initialize the MATLAB runtime in the following way, so that "noopengl" is used:
MWApplication.initialize(new MWMCROption(){public String[] toStringArray(){return new String[] {"-noopengl"};}});
More Answers (0)
See Also
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!