Running matlab code from bash gives Java error

조회 수: 16 (최근 30일)
Fedor Dumas
Fedor Dumas 2022년 10월 6일
답변: Suraj 2023년 9월 12일
What I run:
matlab -nodesktop -nosplash -r "try; name_of_matlab_code.m; catch; end; quit"
What I obtain:
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b Update 3 (9.11.0.1873467) 64-bit (glnxa64)
February 3, 2022
To get started, type doc.
For product information, visit www.mathworks.com.
java.lang.ExceptionInInitializerError
at com.mathworks.mde.editor.plugins.editordataservice.debug.DebuggerInstaller.initializeListeners(DebuggerInstaller.java:92)
at com.mathworks.mde.editor.plugins.editordataservice.debug.DebuggerInstaller.<init>(DebuggerInstaller.java:78)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at com.mathworks.services.editordataservice.EditorDataServiceManager.initializeSingletonEditorFeatures(EditorDataServiceManager.java:120)
at com.mathworks.services.editordataservice.EditorDataServiceManager.initialize(EditorDataServiceManager.java:95)
at com.mathworks.matlabserver.connector.impl.ConnectorImpl.startEditor(ConnectorImpl.java:564)
at com.mathworks.matlabserver.connector.impl.ConnectorImpl.doStart(ConnectorImpl.java:421)
at com.mathworks.matlabserver.connector.impl.ConnectorImpl$1.lambda$run$0(ConnectorImpl.java:193)
Caused by: com.mathworks.util.ShutdownRuntimeException: Java is shutting down
at com.mathworks.mvm.MvmFactory.nativeGetCurrentMvmHandle(Native Method)
at com.mathworks.mvm.MvmFactory.getCurrentMVM(MvmFactory.java:674)
at com.mathworks.mlwidgets.stack.StackInfoRegistry.<clinit>(StackInfoRegistry.java:44)
... 12 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.mathworks.matlabserver.connector.impl.ConnectorLifecycleHelperImpl.callConnectorStarted(ConnectorLifecycleHelperImpl.java:108)
at com.mathworks.matlabserver.connector.impl.ConnectorImpl$1.lambda$run$0(ConnectorImpl.java:198)
Caused by: com.mathworks.util.ShutdownRuntimeException: Java is shutting down
at com.mathworks.mvm.MvmFactory.nativeGetCurrentMvmHandle(Native Method)
at com.mathworks.mvm.MvmFactory.getCurrentMVM(MvmFactory.java:674)
at com.mathworks.mvm.context.MvmContext.get(MvmContext.java:100)
at com.mathworks.services.settings.SettingPath.<init>(SettingPath.java:213)
at com.mathworks.pathdataservice.PathDataService.getEphemeralRootsSetting(PathDataService.java:288)
at com.mathworks.pathdataservice.PathDataService.updateEphemeralRoots(PathDataService.java:325)
at com.mathworks.pathdataservice.PathDataService.startService(PathDataService.java:102)
at com.mathworks.pathdataservice.PathDataService.start(PathDataService.java:72)
at com.mathworks.pathdataservice.PathDataService.startListening(PathDataService.java:66)
... 6 more
The strange thing is that 2 days ago it all worked.
I do not have a big knowledge of bash, so please be more explicit you can.
I have also an other question: is there a way to launch the code without obtain the intial MATLAB text on the terminal (below)?
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b Update 3 (9.11.0.1873467) 64-bit (glnxa64)
February 3, 2022
To get started, type doc.
For product information, visit www.mathworks.com.
Thank you for your help!

답변 (1개)

Suraj
Suraj 2023년 9월 12일
Greetings Fedor,
I see that you’re facing an error when trying to run MATLAB from bash.
Here are a few pointers to keep in mind:
  1. Use just the name of your script without the ".m" extension.
  2. When automating MATLAB scripts, please use the “-batch” flag. The initial MATLAB text will be hidden from the output in this mode.
Your bash command would then look something like this -
matlab -batch "try; name_of_matlab_script; catch; end; quit"
You can learn more about starting a MATLAB program from the Linux terminal here: https://www.mathworks.com/help/matlab/ref/matlablinux.html
Furthermore, the error you've encountered is benign and is fixed since R2022a. Please update your MATLAB version to fix this error. Read more about this here: https://www.mathworks.com/support/bugreports/2613427
I hope this helps.
Thanks & regards,
Suraj.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by