How to programmatically determine if in headless mode..?
19 views (last 30 days)
Show older comments
I'm working on an issue with the Parallel Computing Toolbox (PCT)..
As each MATLAB.exe worker thread process is initialized, startup.m is executed. All worker threads are "headless" (no output window). Certain graphics-related function calls that are fine-- when launched within the full MATLAB app with its output capability-- can cause problems in the headless context.
I have a graphics-related function that's very convenient to have in the full MATLAB app's startup.m, but mustn't execute in the PCT worker thread context. Is there a function call I can insert into startup.m to determine if its MATLAB.exe process is running in headless mode? I would like to use as follows:
% Is there an output window associated with this MATLAB.exe process?
if ~isInHeadlessMode()
% YES : render graphics window
someGraphicsFunction();
end
Any help appreciated, Thanks, Brad
0 Comments
Accepted Answer
Edric Ellis
on 16 Jan 2012
One option is to check:
java.lang.System.getProperty( 'java.awt.headless' )
3 Comments
Edric Ellis
on 18 Jan 2012
FWIW, "usejava('desktop')" is fine for most purposes, but it's not quite the same thing - for example, if you run MATLAB in "-nodesktop" mode (as I do most of the time), then it will give you the wrong answer - you can still produce graphics in "-nodesktop" mode. Oh, and I'm a MathWorker too ;)
More Answers (1)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!