Undocumented startup option / Starting MATLAB GUI from Java

10 次查看(过去 30 天)
Hi, we are using MATLAB R2018b on Windows 10 Enterprise and trying to automate the MATLAB execution from Java.
Firstly, consider the following scenarios starting MATLAB from the Windows Command Prompt:
i) matlab
It expectedly shows the splash screen, opens the MATLAB GUI with the clear Command Window and Workspace.
ii) matlab -nojvm
It expectedly shows the splash screen, does not open the MATLAB GUI but the plain and clear MATLAB Command Window instead.
iii) matlab -jvvm
It expectedly shows the splash screen, opens the MATLAB GUI with the following warning in Command Window and clear Workspace:
Warning: Unrecognized command line option: jvvm.
iv) matlab -jvm
It shows the splash screen, opens the MATLAB GUI with the clear Command Window and Workspace, i.e. no warning about Unrecognized command line option is raised.
It seems that the naive try with option -jvm succeeded although such option is not documented at all (we checked the documentation for many different MATLAB releases, hopefully have not missed anything in this context).
Nevertheless, it is surprising that the option -nojvm is declared to be used only for "Mac and Linux® platforms" (https://www.mathworks.com/help/releases/R2018b/matlab/matlab_env/commonly-used-startup-options.html), and this is a common thing, not only for R2018b.
So, here are some questions:
1. Why the option -nojvm is not declared to be used for "Windows® platforms" as well, i.e. for "All"?
2. It seems that the option -jvm really exists and it is not documented anywhere, not even in "for some -no* options, there are opposites that can be used to achieve the opposite effect"? Why isn't that documented, and will it be?
The motivation behind the previous scenarios was that starting the MATLAB engine from Java (explained here for example: https://www.mathworks.com/help/releases/R2018b/matlab/matlab_external/start-matlab-session-from-java.html ) does not open the MATLAB GUI, which we explicitly want. So we tried to test various startup options and naively got into the "non-existing" -jvm option. That one definitely helped to raise the MATLAB GUI from Java but we wanted to get the confirmation that we can reliably use that option.
Regards, Ivan
  3 个评论
Ivan Kokan
Ivan Kokan 2022-2-22
No difference when calling such from the Windows Command Prompt. But there is a difference when starting MATLAB from Java, as explained at the end of my original post.
Jan
Jan 2022-2-23
In this example you do not start Matlab, but the Matlab-Engine. This is a difference. If you want to start Matlab with a GUI, using this would be less indirect:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command);
process.waitFor();

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2022-2-16
As far as I remember, starting Matlab with the Java VM was optional in Matlab 4 or 5. So you could enable the JVM manually. Therefore the -jvm flag might be kept for backward compatibility.
I do not see, why -nojvm concerns Macs and Linux only.
  2 个评论
Ivan Kokan
Ivan Kokan 2022-2-22
Thanks for the feedback. I still wait for some official explanation and guidance.
Bruno Luong
Bruno Luong 2022-2-22
Usualy TMW don't comment on things that are not documented and make any comment on "features" that go beyong the official documentation.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by