Unable to run EngineGUIDemo in Java Engine

8 ビュー (過去 30 日間)
Alex Phung
Alex Phung 2016 年 11 月 19 日
コメント済み: Justin Livermore 2023 年 8 月 8 日
I followed the directions in the README file, but I still get the error:
c:\Temp\MATLABJavaEngine>java -Djava.library.path="c:\Program Files\MATLAB\R2016b\bin\win64" -classpath .;"c:\Program Files\MATLAB\R2016b\extern\engines\java\jar\engine.jar" EngineConsoleDemo Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\MATLAB\R2016b\bin\win64\nativemvm.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.mathworks.mvm.MvmImpl.loadLibrary(MvmImpl.java:107)
at com.mathworks.mvm.MvmImpl.setJavaEngineMode(MvmImpl.java:202)
at com.mathworks.engine.MatlabEngine.<clinit>(MatlabEngine.java:69)
at EngineConsoleDemo.main(EngineConsoleDemo.java:16)
Failed to load nativemvm library: C:\Program Files\MATLAB2016b\bin\win64\nativemvm.dll: Can't find dependent libraries

回答 (2 件)

J.Eric Tkaczyk
J.Eric Tkaczyk 2017 年 2 月 13 日
I had the same problem and solved it in the following way.
First allow this dll you are loading to see all the other dlls it depends upon. You do this by editing the Windows Environment PATH variable to include C:\Program Files\MATLAB\R2016b\bin\win64\
Then add dependency to your module to engine.jar. In IntelliJ this is done in ProjectStrucuture/Modules/yourModule dialog box and select the dependency tab, plus sign and navigate to your engine.jar location
Make all the dlls needed for java by including this command line argument in the run configuration: -Djava.library.path="C:\Program Files\MATLAB\R2016b\bin\win64"
Now include this as the first line of you main method to have all the methods available to your application: System.loadLibrary("nativemvm");
  3 件のコメント
Chibing Gng
Chibing Gng 2017 年 2 月 20 日
Dear Alex Phung and J.Eric Tkaczyk,
I installed Matlab 2016b, but no extern\engines\java\jar\engine.jar. Could you tell me how you installed ?
Thanks Spencer
Bo Li
Bo Li 2017 年 3 月 15 日
This file is part of the R2016b MATLAB installation by default.

サインインしてコメントする。


Bo Li
Bo Li 2017 年 3 月 15 日
Adding "<matlabroot>/bin/win64" to the system environment variable PATH is required, otherwise, Java doesn't know where to find the dynamic shared libraries. "-Djava.library.path" helps only in finding the native library directly used by the Java file, but it doesn't help the native library to find its dependent libraries.
If requesting a user to set the PATH is not desired, maybe the Java command can be placed in a batch file which sets the PATH before running the Java command.
  2 件のコメント
James Hong
James Hong 2020 年 4 月 22 日
Also, make sure that the entry is added to the top of the PATH environment variable.
Justin Livermore
Justin Livermore 2023 年 8 月 8 日
Thank you. I added it to the top and it fixed my issue. Glad I found this.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeJava Package Integration についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by