简体   繁体   English

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

[英]JDK 7/JavaFX 2 application on Mac OSX El Capitan

I've just upgraded to El Capitan and I'm running into problems starting a custom JavaFX2 application running under JDK1.7.0u79 (the latest available from Oracle). 我刚刚升级到El Capitan,我在启动在JDK1.7.0u79下运行的自定义JavaFX2应用程序时遇到问题(Oracle提供的最新版本)。

When starting the app, I'm getting this 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.<init>(Text.java:153)
    at javafx.scene.text.Text.<init>(Text.java:162)
    at com.sun.javafx.scene.control.skin.ProgressIndicatorSkin.<clinit>(ProgressIndicatorSkin.java:78)
    ... 37 more

I can't just migrate the app to Java 8, so any help is much appreciated. 我不能只将应用程序迁移到Java 8,所以非常感谢任何帮助。

Update 更新

I've been able to get the app running again by adding this to the start of my main method. 通过将其添加到我的main方法的开头,我已经能够让应用程序再次运行。 Any better solutions out there? 还有更好的解决方案吗?

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

After more than a week with that in an extensive enterprise application, I haven't noticed any problems in the UI. 在广泛的企业应用程序中使用一周以上之后,我没有注意到UI中的任何问题。

For the lack of a better solution, I'm accepting my update above as answer. 由于缺乏更好的解决方案,我接受上面的更新作为答案。 Maybe it helps someone... 也许它有助于某人......

I've been able to get the app running again by adding this to the start of my main method. 通过将其添加到我的main方法的开头,我已经能够让应用程序再次运行。

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

This isn't a direct answer, however I thought it important to pass on that this bug has been identified and fixed in an upcoming Java release. 这不是一个直接的答案,但我认为重要的是传递这个bug已经在即将发布的Java版本中被识别和修复。 See https://bugs.openjdk.java.net/browse/JDK-8143907 请参阅https://bugs.openjdk.java.net/browse/JDK-8143907

I had the same problem. 我有同样的问题。 I changed the Text to a Label. 我将文本更改为标签。 I'm not sure it's possible in your case. 我不确定你的情况是否可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM