Mac OSX El Capitan上的JDK 7 / JavaFX 2应用程序

我刚刚升级到El Capitan,我在启动在JDK1.7.0u79(Oracle最新版本)下运行的自定义JavaFX2应用程序时遇到了问题。

启动应用程序时,我遇到了以下exception:

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:745) Caused by: java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:191) at javafx.scene.control.Control.loadClass(Control.java:115) at javafx.scene.control.Control.loadSkinClass(Control.java:1021) at javafx.scene.control.Control.access$500(Control.java:70) at javafx.scene.control.Control$12.invalidated(Control.java:972) at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:127) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161) at com.sun.javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:71) at javafx.scene.control.Control$12.set(Control.java:964) at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:59) at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:31) at com.sun.javafx.css.StyleableProperty.set(StyleableProperty.java:70) at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:900) at javafx.scene.Node.impl_processCSS(Node.java:7418) at javafx.scene.Parent.impl_processCSS(Parent.java:1146) at javafx.scene.control.Control.impl_processCSS(Control.java:1154) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Node.processCSS(Node.java:7386) at javafx.scene.Scene.doCSSPass(Scene.java:454) at javafx.scene.Scene.preferredSize(Scene.java:1468) at javafx.scene.Scene.impl_preferredSize(Scene.java:1535) at javafx.stage.Window$9.invalidated(Window.java:717) 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:781) at javafx.stage.Window.show(Window.java:796) at javafx.stage.Stage.show(Stage.java:233) at au.com.religaresecurities.trademax.client.Start.start(Start.java:131) at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319) at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219) at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182) at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76) Caused by: java.lang.NullPointerException at com.sun.t2k.MacFontFinder.initPSFontNameToPathMap(MacFontFinder.java:339) at com.sun.t2k.MacFontFinder.getFontNamesOfFontFamily(MacFontFinder.java:390) at com.sun.t2k.T2KFontFactory.getFontResource(T2KFontFactory.java:233) at com.sun.t2k.LogicalFont.getSlot0Resource(LogicalFont.java:184) at com.sun.t2k.LogicalFont.getSlotResource(LogicalFont.java:228) at com.sun.t2k.CompositeStrike.getStrikeSlot(CompositeStrike.java:86) at com.sun.t2k.CompositeStrike.getMetrics(CompositeStrike.java:132) at com.sun.javafx.font.PrismFontUtils.getFontMetrics(PrismFontUtils.java:31) at com.sun.javafx.font.PrismFontLoader.getFontMetrics(PrismFontLoader.java:466) at javafx.scene.text.Text.(Text.java:153) at javafx.scene.text.Text.(Text.java:162) at com.sun.javafx.scene.control.skin.ProgressIndicatorSkin.(ProgressIndicatorSkin.java:78) ... 37 more 

我不能只将应用程序迁移到Java 8,所以非常感谢任何帮助。

更新

通过将其添加到我的main方法的开头,我已经能够让应用程序再次运行。 还有更好的解决方案吗?

  try { Class macFontFinderClass = Class.forName("com.sun.t2k.MacFontFinder"); Field psNameToPathMap = macFontFinderClass.getDeclaredField("psNameToPathMap"); psNameToPathMap.setAccessible(true); psNameToPathMap.set(null, new HashMap()); } catch (Exception e) { // ignore } 

在广泛的企业应用程序中使用了一周以上之后,我没有注意到UI中的任何问题。

由于缺乏更好的解决方案,我接受上面的更新作为答案。 也许它有助于某人……

通过将其添加到我的main方法的开头,我已经能够让应用程序再次运行。

  try { Class macFontFinderClass = Class.forName("com.sun.t2k.MacFontFinder"); Field psNameToPathMap = macFontFinderClass.getDeclaredField("psNameToPathMap"); psNameToPathMap.setAccessible(true); psNameToPathMap.set(null, new HashMap()); } catch (Exception e) { // ignore } 

这不是一个直接的答案,但我认为重要的是传递这个bug已经在即将发布的Java版本中被识别和修复。 请参阅https://bugs.openjdk.java.net/browse/JDK-8143907

我有同样的问题。 我将文本更改为标签。 我不确定你的情况是否可行。