2

Just tried to run my old tests in java-9 and see them not running at all due to an exception thrown by the code that guarantees running on the FX-threaad (the ol' trick to instantiate a JFXPanel)

The stand-alone example below (it's the plain tutorial code) throws it as well:

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)

Environment is win7, jdk9-ea-107 (without jigsaw), eclipse-neon-ea - questions are simple: a) what's wrong exactly, b) how to fix?

The exact output of java -version is:

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)

The code:

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();
            }
        });
    }
}

Update

tried both suggestions in the comments (updating to most recent 9-ea-107, running from the command line) - no success, same exception.

Another observation: the example above fails with the same stacktrace even when all fx related code is commented - plain swing won't run. Looks like something severely wrong in my environment.

kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • That works for me (getting a "Welcome JavaFX" Window) with `Java(TM) SE Runtime Environment (build 9-ea+107-2016-02-24-182456.javare.4520.nc)` `Java HotSpot(TM) 64-Bit Server VM (build 9-ea+107-2016-02-24-182456.javare.4520.nc, mixed mode)`. I compiled and run from the command line though, not from within Eclipse. BTW, +1 for motivating me to install the jdk9 EA :) – Andreas Fester Mar 01 '16 at 15:18
  • 1
    Ah, just noticed that we are at ea-107 meanwhile - could you retry with that version? https://jdk9.java.net/download/ – Andreas Fester Mar 01 '16 at 15:20
  • @AndreasFester thanks for taking all the trouble :-) Will try both the command line and the newer ea! On my lazy side, I'm waiting out a bit longer on further comments/answers – kleopatra Mar 01 '16 at 15:23
  • @AndreasFester commandline seems to throw the same error (though I'm far from confident I used it correctly, haven't in years ;-) So will download a newer version and check tomorrow or so. – kleopatra Mar 01 '16 at 16:17
  • @AndreasFester The 107 build does not include Jigsaw, which I suspect is the source of the problem. – Oliver Jan Krylow Mar 02 '16 at 09:51
  • @OJKrylow I'm using the 9-version without jigsaw (should clarify!) Will install the most recent later today, then we'll see if it helps, thanks – kleopatra Mar 02 '16 at 09:58
  • @AndreasFester thanks for being still with me :-) Meanwhile, I detected that it's unrelated to fx - can't run plain Swing .. – kleopatra Mar 02 '16 at 11:01
  • @AndreasFester will try another machine soon, something really weird going on here ... – kleopatra Mar 02 '16 at 11:07
  • I quickly verified with the 32 bit client VM you were using (version numbers match exactly) and it still works ... – Andreas Fester Mar 02 '16 at 11:25
  • @AndreasFester thanks again for all your effort :-) Your result strengthens my feeling that there's something wrong on the particular machine I'm running right now .. will come back once I tried on another (tomorrow or so). – kleopatra Mar 02 '16 at 12:30

0 Answers0