Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run GUI application in a headless way in Mac?

I'm using following techniques to run GUI application in Linux and Windows:

Linux:

:~$ Xvfb :99 -ac &
:~$ DISPLAY=:99 ./app

This won't work for 100% in Mac OS X, even though Xvfb is installed by default, since most applications run in Aqua environment, and simply ignore DISPLAY variable setting.

Windows (programmatic way):

HDESK hDesk=CreateDesktop(TEXT("Virtual"),NULL,NULL,NULL,GENERIC_ALL,NULL);
if(hDesk!=NULL) {
   // create process in this desktop
   CloseDesktop(hDesk);
}

Mac OS X:

How do I do the same in Mac OS X (either from command line or in a programmatic way)? Thanks!

like image 546
Michael Spector Avatar asked Jan 25 '12 12:01

Michael Spector


1 Answers

Is this a Java question? I don't recognize either the HDESK nor the CreateDesktop call, but in the JVM itself, you can run headless pretty much anywhere by invoking java with the headless System Property defined...

java -Djava.awt.headless=true

I've had success with this on Windows and Linux at least. I would expect it to work on OS X in the same manner. The article explains it pretty well: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/

like image 197
Bob Kuhar Avatar answered Sep 30 '22 03:09

Bob Kuhar