Mac OSX El Capitan上的JDK 7 / JavaFX 2应用程序 [英] JDK 7/JavaFX 2 application on Mac OSX El Capitan

查看:97
本文介绍了Mac OSX El Capitan上的JDK 7 / JavaFX 2应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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).

启动应用程序时,我遇到此异常:

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

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

I can't just migrate the app to Java 8, so any help is much appreciated.

更新

通过添加此功能,我已经能够让应用再次运行到我的主要方法的开始。那里有更好的解决方案吗?

I've been able to get the app running again by adding this to the start of my main method. 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
    }


推荐答案

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

After more than a week with that in an extensive enterprise application, I haven't noticed any problems in the UI.

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

For the lack of a better solution, I'm accepting my update above as answer. Maybe it helps someone...

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

I've been able to get the app running again by adding this to the start of my main method.

    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
    }

这篇关于Mac OSX El Capitan上的JDK 7 / JavaFX 2应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆