osx - How to run java UI application on Mac from remote ssh terminal? -


on mac can connect ssh , run applications without display settings, e.g. open . run finder on mac screen remote terminal.

this doesn't work java applications:

java -jar demo/jfc/font2dtest/font2dtest.jar  

will throw:

exception in thread "main" java.awt.headlessexception @ java.awt.graphicsenvironment.checkheadless(graphicsenvironment.java:207) @ java.awt.window.<init>(window.java:536) @ java.awt.frame.<init>(frame.java:420) @ javax.swing.jframe.<init>(jframe.java:225) @ font2dtest.main(font2dtest.java:1032) 

any experiments display values didn't help.

in jdk8 can use awt_force_headful env variable overcome this:

awt_force_headful=true java -jar demo/jfc/font2dtest/font2dtest.jar  

unfortunately there no easy way in jdk7.

the problem hidden in mac headless mode detection. next code checks app being in "aqua" session , forces headless otherwise.

// jdk/src/solaris/native/java/lang/java_props_macosx.c int isinaquasession() {   // environment variable bypass aqua session check   char *ev = getenv("awt_force_headful");   if (ev && (strncasecmp(ev, "true", 4) == 0)) {     // if "true" tell caller we're in aqua session without checking     return 1;   }   // windowserver available?   securitysessionid session_id;   sessionattributebits session_info;   osstatus status = sessiongetinfo(callersecuritysession, &session_id, &session_info);   if (status == noerr) {     if (session_info & sessionhasgraphicaccess) {         return 1;     }   }   return 0;  } 

and

// jdk/src/solaris/native/java/lang/java_props_md.c  // check if we're in gui login session , set java.awt.headless=true if not sprops.awt_headless = isinaquasession() ? null : "true"; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -