JFXPanel在java-9中抛出UnsatisfiedLinkError - 如何修复?

时间:2016-03-01 14:52:03

标签: eclipse swing javafx-8 java-9 jfxpanel

只是尝试在java-9中运行我的旧测试并看到它们根本没有运行,因为代码抛出的异常保证在FX-threaad上运行(实例化JFXPanel的技巧)

下面的独立示例(这是简单的教程代码)也会抛出它:

Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\java\jdk\190_ea\bin\awt.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1935)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1841)
at java.lang.Runtime.loadLibrary0(Runtime.java:874)
at java.lang.System.loadLibrary(System.java:1770)
at java.awt.Toolkit$3.run(Toolkit.java:1355)
at java.awt.Toolkit$3.run(Toolkit.java:1353)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1352)
at java.awt.Toolkit.<clinit>(Toolkit.java:1387)
at java.awt.EventQueue.invokeLater(EventQueue.java:1268)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1381)
at de.swingempire.fx.swing.JFXPanelExample.main(JFXPanelExample.java:59)

环境是win7,jdk9-ea-107(没有拼图),eclipse-neon-ea - 问题很简单:a)究竟有什么不对,b)如何修复?

java -version的确切输出是:

java version "9-ea" Java(TM) SE Runtime Environment (build   9-ea+107-2016-02-24-175644.javare.4520.nc) 
Java HotSpot(TM) Client VM (build 9-ea+107-2016-02-24-175644.javare.4520.nc, mixed mode)

代码:

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class JFXPanelExample {

    private static void initAndShowGUI() {
        // This method is invoked on the EDT thread
        JFrame frame = new JFrame("Swing and JavaFX");
        final JFXPanel fxPanel = new JFXPanel();
        frame.add(fxPanel);
        frame.setSize(300, 200);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                initFX(fxPanel);
            }
       });
    }

    private static void initFX(JFXPanel fxPanel) {
        // This method is invoked on the JavaFX thread
        Scene scene = createScene();
        fxPanel.setScene(scene);
    }

    private static Scene createScene() {
        Group  root  =  new  Group();
        Scene  scene  =  new  Scene(root, Color.ALICEBLUE);
        Text  text  =  new  Text();

        text.setX(40);
        text.setY(100);
        text.setFont(new Font(25));
        text.setText("Welcome JavaFX!");

        root.getChildren().add(text);

        return (scene);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                initAndShowGUI();
            }
        });
    }
}

更新

在评论中尝试了两个建议(更新到最近的9-ea-107,从命令行运行) - 没有成功,同样的例外。

另一个观察结果:即使所有与fx相关的代码都被注释,上面的示例也会失败并显示相同的堆栈跟踪 - 无法运行普通的swing。在我的环境中看起来像是严重错误的东西。

0 个答案:

没有答案