为什么我不能在Eclipse上编译javaFX项目

时间:2019-04-24 10:37:21

标签: java eclipse javafx

我无法在Eclipse IDE上运行任何javaFX项目,一旦我编译代码,它就会向我显示一堆错误

我尝试了一堆简单的代码,但都不成功,它总是向我显示相同的错误

import javafx.scene.paint.Color;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {


        Group root = new Group();
        Scene scene = new Scene(root,400,400,Color.BLACK);

        Circle cir = new Circle(200,200,100);
        cir.setFill(Color.CORAL);
        root.getChildren().add(cir);

        primaryStage.setTitle("JavaFX Scene Graph Example");
        primaryStage.setScene(scene);
        primaryStage.show();

        }


    public static void main(String[] args) {
            launch(args);
        }

    }

///////////////////////////////////      这是我得到的结果:

 Exception in thread "main"           java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
     at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
 Caused by: java.lang.RuntimeException:
  java.lang.UnsatisfiedLinkError:      com.sun.glass.ui.gtk.GtkApplication._isDisplayValid()Z
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267)
     at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
     at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
     at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
     at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
     ... 5 more
 Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._isDisplayValid()Z
     at com.sun.glass.ui.gtk.GtkApplication._isDisplayValid(Native Method)
     at com.sun.glass.ui.gtk.GtkApplication.isDisplayValid(GtkApplication.java:83)
     at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:67)
     at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
     at com.sun.glass.ui.Application.run(Application.java:146)
     at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
... 9 more

0 个答案:

没有答案