Undocumented startup option / Starting MATLAB GUI from Java
    2 views (last 30 days)
  
       Show older comments
    
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 Comments
  Jan
      
      
 on 23 Feb 2022
				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();
Answers (1)
  Jan
      
      
 on 16 Feb 2022
        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.
Several feature will not work with the Java VM: https://www.mathworks.com/matlabcentral/answers/102417-how-does-nojvm-mode-affect-matlab-simulink 
I do not see, why -nojvm concerns Macs and Linux only. 
2 Comments
  Bruno Luong
      
      
 on 22 Feb 2022
				Usualy TMW don't comment on things that are not documented and make any comment on "features" that go beyong the official documentation.
See Also
Categories
				Find more on Startup and Shutdown 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!

