JDK-7144064 : [macosx] "Could not find class" error in JTree's ctor when called in headless mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7,7u4
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-02-09
  • Updated: 2012-10-01
  • Resolved: 2012-03-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u4 b13Fixed 8Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Here is a very simple test which throws error on Mac:

import java.awt.Toolkit;
import javax.swing.JTree;

public final class JTreeTest {
    public static void main(final String... args) {
        System.setProperty("java.awt.headless", "true");
        final JTree tree = new JTree();

The error is:
Exception in thread "main" java.lang.Error: Could not find class: sun.awt.HeadlessGraphicsEnvironment
        at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:116)
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
        at sun.swing.SwingUtilities2.isLocalDisplay(SwingUtilities2.java:1457)
        at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1556)
        at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:148)
        at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1592)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:535)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:575)
        at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1343)
        at javax.swing.UIManager.initialize(UIManager.java:1432)
        at javax.swing.UIManager.maybeInitialize(UIManager.java:1420)
        at javax.swing.UIManager.getUI(UIManager.java:1002)
        at javax.swing.JTree.updateUI(JTree.java:714)
        at javax.swing.JTree.<init>(JTree.java:667)
        at javax.swing.JTree.<init>(JTree.java:564)
        at JTreeTest.main(JTreeTest.java:8)
Version of jdk:
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b227)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b12, mixed mode)

EVALUATION In src/solaris/native/java/lang/java_props_md.c: #ifdef MACOSX break; default: sprops.graphics_env = "sun.awt.HeadlessGraphicsEnvironment"; break; } #endif This is obviously wrong as HeadlessGraphicsEnvironment is in the sun.java2d package.