title: Could not initialize class com.sun.javafx.css.StyleHelper
body: <p>I'm trying to run my first JavaFX example, and I'm stumped because I cannot get the following example to run.  I have read related items about java.lang.NoClassDefFoundError and I'm guessing it's a CLASSPATH issue, but I'm still new enough to java that I could not figure out what the problem might be from the other similar question here and elsewhere on the Internet.  The same error occurs whether CLASSPATH is NOT set, or set to the value listed at the end.  Any pointers would be much appreciated.</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class HelloWorld extends Application {
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) {
          primaryStage.setTitle("Hello World!");
          Button btn = new Button();
          btn.setText("Say 'Hello World'");
          btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
              @Override
              public void handle(ActionEvent event) {
                  System.out.println("Hello World!");
              }
          });
  
          StackPane root = new StackPane();
          root.getChildren().add(btn);
          primaryStage.setScene(new Scene(root, 300, 250));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>It compiles, but when I run it I get the following stack trace:</p>
  
  <pre><code>&gt; javac HelloWorld.java 
  &gt; java HelloWorld
  Exception in Application start method
  java.lang.NoClassDefFoundError: Could not initialize class com.sun.javafx.css.StyleHelper
  at com.sun.javafx.css.StyleManager$StylesheetContainer.getStyleHelper(StyleManager.java:1390)
  at com.sun.javafx.css.StyleManager$StylesheetContainer.access$1300(StyleManager.java:1039)
  at com.sun.javafx.css.StyleManager.getStyleHelper(StyleManager.java:976)
  at javafx.scene.Node.impl_createStyleHelper(Node.java:7433)
  at javafx.scene.Node.impl_processCSS(Node.java:7403)
  at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
  at javafx.scene.Node.processCSS(Node.java:7383)
  at javafx.scene.Scene.doCSSPass(Scene.java:446)
  at javafx.scene.Scene.access$3800(Scene.java:170)
  at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2202)
  at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
  at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
  at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
  at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
  at java.lang.Thread.run(Thread.java:722)
  Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
  at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
  at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
  at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.ExceptionInInitializerError
  at com.sun.javafx.css.StyleManager$StylesheetContainer.getStyleHelper(StyleManager.java:1390)
  at com.sun.javafx.css.StyleManager$StylesheetContainer.access$1300(StyleManager.java:1039)
  at com.sun.javafx.css.StyleManager.getStyleHelper(StyleManager.java:976)
  at javafx.scene.Node.impl_createStyleHelper(Node.java:7433)
  at javafx.scene.Node.impl_processCSS(Node.java:7403)
  at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
  at javafx.scene.Node.processCSS(Node.java:7383)
  at javafx.scene.Scene.doCSSPass(Scene.java:446)
  at javafx.scene.Scene.preferredSize(Scene.java:1449)
  at javafx.scene.Scene.impl_preferredSize(Scene.java:1516)
  at javafx.stage.Window$9.invalidated(Window.java:716)
  at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
  at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
  at javafx.stage.Window.setShowing(Window.java:779)
  at javafx.stage.Window.show(Window.java:794)
  at javafx.stage.Stage.show(Stage.java:229)
  at HelloWorld.start(HelloWorld.java:30)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
  at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
  ... 1 more
  Caused by: java.lang.NullPointerException
  at com.sun.t2k.LogicalFont.&lt;init&gt;(LogicalFont.java:172)
  at com.sun.t2k.LogicalFont.getLogicalFont(LogicalFont.java:104)
  at com.sun.t2k.LogicalFont.getLogicalFont(LogicalFont.java:144)
  at com.sun.t2k.T2KFontFactory.createFont(T2KFontFactory.java:356)
  at com.sun.prism.j2d.J2DFontFactory.createFont(J2DFontFactory.java:38)
  at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:399)
  at javafx.scene.text.Font.&lt;init&gt;(Font.java:282)
  at javafx.scene.text.Font.getDefault(Font.java:85)
  at com.sun.javafx.css.StyleHelper.&lt;clinit&gt;(StyleHelper.java:1600)
  ... 27 more
  </code></pre>
  
  <p>Some other details:</p>
  
  <pre><code>Red Hat Enterprise Linux 6.2 on x64
  jdk1.7.0_21
  &gt; printenv CLASSPATH
  .:/usr/java/jdk1.7.0_21/jre/lib/*:/usr/java/jdk1.7.0_21/jre/lib/ext/*
  </code></pre>
  
  <p>There are multiple jdks installed, but I checked to be sure that both javac and java point to the jdk1.7.0_21 version.</p>
  
  <p>I've search Oracle's web site, this site, and a few other Internet sites, but not found mention of this error related to JavaFX.</p>