[SOLVED] HeadlessException while running examples on OSX with JDK 8

I am getting a HeadlessException while attempting to run the JME3 examples,

./gradlew run

on OSX High Sierra with jdk1.8.0_152:

> Task :jme3-examples:run
Exception in thread "main" java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1758)
        at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1833)
        at javax.swing.JDialog.<init>(JDialog.java:272)
        at javax.swing.JDialog.<init>(JDialog.java:233)
        at jme3test.TestChooser.<init>(TestChooser.java:86)
        at jme3test.TestChooser.main(TestChooser.java:451)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jme3-examples:run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

39 actionable tasks: 2 executed, 37 up-to-date

Changing this to set headless to false in build.gradle does not fix the problem:

jvmArgs "-Djava.awt.headless=true"

By commenting out lines 10-13 of build.gradle, i was able to run the examples on OSX High Sierra with JDK 8:

//    if (System.properties['os.name'].toLowerCase().contains('mac')) {
//        jvmArgs "-XstartOnFirstThread"
//        jvmArgs "-Djava.awt.headless=true"
//    }