I get an error message while using a JAR that is compiled by Library Compiler

조회 수: 4 (최근 30일)
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?

채택된 답변

Mathias
Mathias 2025년 3월 6일
편집: Mathias 2025년 3월 6일
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"};}});
  댓글 수: 1
Cagri
Cagri 2025년 3월 7일
편집: Cagri 2025년 3월 7일
Thank you very much Mathias! My application is compiled as a library, so -noopengl flag didn't work, since it is for standalone applications. However, initializing the MATLAB runtime as you suggested worked like a charm.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by