First of all, here is a list of relevant startup options, along with the operating system on which they are supported (otherwise they are ignored and have no effect):
-nojvm
[UNIX] : start without JVM, anything that requires Java fails (including Handle Graphics functionality)
-nodisplay
[UNIX]: does not use X-Window display, ignores $DISPLAY
environment variable
-noFigureWindows
[ALL] : headless mode, no figure will be shown
-nodesktop
[ALL] : IDE not started, command prompt instead
Since I only have access to a Windows install of MATLAB, I would be thankful If someone can replicate the following experiments on UNIX, by starting MATLAB with the -nodisplay
option, or runing without the DISPLAY
environment variable set, in combination with the -nodisplay
and -nojvm
options.
matlab -nodesktop
? [usejava('jvm'),usejava('awt'),usejava('mwt'),usejava('Desktop')]
ans =
1 1 1 0
? get(0,'ScreenSize')
ans =
1 1 1600 1024
? feature('ShowFigureWindows')
ans =
1
? questdlg('?','?');
[works fine]
? plot(1:10)
[works fine]
matlab -noFigureWindows
? [usejava('jvm'),usejava('awt'),usejava('mwt'),usejava('Desktop')]
ans =
1 1 1 1
? get(0,'ScreenSize')
ans =
1 1 1600 1024
? feature('ShowFigureWindows')
ans =
0
? questdlg('?','?');
Warning: This functionality is no longer supported ....
? plot(1:10)
[no plot]
matlab -nodesktop -noFigureWindows
? [usejava('jvm'),usejava('awt'),usejava('mwt'),usejava('Desktop')]
ans =
1 1 1 0
? get(0,'ScreenSize')
ans =
1 1 1600 1024
? feature('ShowFigureWindows')
ans =
0
? questdlg('?','?');
Warning: This functionality is no longer supported ....
? plot(1:10)
[no plot]
In conclusion, this is the test I would use to get consistent results across platforms:
if usejava('jvm') && ~feature('ShowFigureWindows')
%# use text-based alternative (input)
else
%# use GUI dialogs (questdlg)
end
Some references:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…