JavaFx应用程序在具有相同java配置的不同机器上显示错误

JavaFx应用程序在具有相同java配置的不同机器上显示错误,java,eclipse,javafx,Java,Eclipse,Javafx,我使用的是Ubuntu 14.04和Oracle Java 8_45。我已经设置了JAVA_HOME和PATH变量。下面是尝试在eclipse上运行的终端输出。 但是,相同的应用程序在具有相同配置的不同机器上运行良好 Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at com.sun.javafx.Utils.getScreen(Utils.java:686) at com.sun.j

我使用的是Ubuntu 14.04和Oracle Java 8_45。我已经设置了JAVA_HOME和PATH变量。下面是尝试在eclipse上运行的终端输出。 但是,相同的应用程序在具有相同配置的不同机器上运行良好

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.Utils.getScreen(Utils.java:686)
at com.sun.javafx.webkit.WebPageClientImpl.getScreenBounds(WebPageClientImpl.java:105)
at com.sun.webkit.WCWidget.fwkGetScreenRect(WCWidget.java:118)
at com.sun.webkit.network.URLLoader.twkDidFinishLoading(Native Method)
at com.sun.webkit.network.URLLoader.notifyDidFinishLoading(URLLoader.java:830)
at com.sun.webkit.network.URLLoader.lambda$didFinishLoading$95(URLLoader.java:821)
at com.sun.webkit.network.URLLoader$$Lambda$105/91090058.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$53/146033025.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$52/2027961269.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$48(GtkApplication.java:139)
at com.sun.glass.ui.gtk.GtkApplication$$Lambda$41/1327763628.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
这是主类的代码

              import java.awt.SplashScreen;
              import java.util.concurrent.CountDownLatch;

              import javafx.application.Application;
              import javafx.application.Platform;
              import javafx.beans.value.ChangeListener;
              import javafx.beans.value.ObservableValue;
              import javafx.fxml.FXMLLoader;
              import javafx.scene.Parent;
              import javafx.scene.Scene;
              import javafx.scene.image.Image;
              import javafx.stage.Stage;

              public class app extends Application {
             // private Stage primaryStage;
             // private Scene primaryScene;

             @Override
              public void start(Stage stage) {
              try {
              Parent root = FXMLLoader.load(app.class
                .getResource("views/Index.fxml"));
               // default resolution 1000, 730
              Scene scene = new Scene(root, 1000, 710);
              scene.getStylesheets().add("/resource/app.css");
              stage.getIcons().add(
                new Image("/resource/graphics/app_logo.png"));
              stage.setTitle("Opt-app");
              scene.widthProperty().addListener(new ChangeListener<Number>() {
                    @Override
                 public void changed(
                    ObservableValue<? extends Number> observableValue,
                    Number oldSceneWidth, Number newSceneWidth) {

                double screenWidth = Double.parseDouble(newSceneWidth
                        .toString());
                if (screenWidth >= 1000) {
                    Navigation.screenWidth = screenWidth;
                } else {
                    Navigation.screenWidth = 1000;
                }
                Navigation.resizeSceneComponents();

            }
        });
        scene.heightProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(
                    ObservableValue<? extends Number> observableValue,
                    Number oldSceneHeight, Number newSceneHeight) {
                double screenHeight = Double.parseDouble(newSceneHeight
                        .toString());
                // if(screenHeight)
                if (screenHeight >= 710) {
                    Navigation.screenHeight = screenHeight;
                } else {
                    Navigation.screenHeight = 710;
                }
                Navigation.resizeSceneComponents();
            }
        });
        Common.scene = scene;
        Common.mainStage = stage;

        // Get the splashscreen
        final SplashScreen splash = SplashScreen.getSplashScreen();

        // Close splashscreen
        if (splash != null) {
            splash.close();
        }

        stage.setScene(scene);
        stage.show();
    } catch (Exception e) {
        e.printStackTrace();
        Common.print(e);
    }
}

public static void main(String[] args) {
    try {


        Common.print("Starting app...");
        if (SystemConfig.initializingConnection())
                {
            SystemConfig.initCommonProperties();
            Application.launch(app.class, args);
        } else {
            Common.print("app dependency unsatisfied. Please contact to app Team.");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {

    }
}

public static void runAndWait(Runnable action) {
    if (action == null)
        throw new NullPointerException("action");

    // run synchronously on JavaFX thread
    if (Platform.isFxApplicationThread()) {
        action.run();
        return;
    }

    // queue on JavaFX thread and wait for completion
    final CountDownLatch doneLatch = new CountDownLatch(1);
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            try {
                action.run();
            } finally {
                doneLatch.countDown();
            }
        }
    });

    try {
        doneLatch.await();
    } catch (InterruptedException e) {
        // ignore exception
    }
}
导入java.awt.SplashScreen;
导入java.util.concurrent.CountDownLatch;
导入javafx.application.application;
导入javafx.application.Platform;
导入javafx.beans.value.ChangeListener;
导入javafx.beans.value.observeValue;
导入javafx.fxml.fxmloader;
导入javafx.scene.Parent;
导入javafx.scene.scene;
导入javafx.scene.image.image;
导入javafx.stage.stage;
公共类应用程序扩展应用程序{
//私人阶段初级阶段;
//私密场景主要场景;
@凌驾
公众假期开始(阶段){
试一试{
父根=FXMLLoader.load(app.class
.getResource(“views/Index.fxml”);
//默认分辨率1000730
场景=新场景(根,1000710);
scene.getStylesheets().add(“/resource/app.css”);
stage.getIcons().add(
新图像(“/resource/graphics/app_logo.png”);
舞台设置标题(“选择应用程序”);
scene.widthProperty().addListener(新的ChangeListener()){
@凌驾
更改公众假期(

ObserviveValue您是否使用WebView?在这种情况下,您必须在加载页面之前将WebView与场景和舞台相关联。以下是我所做的一些研究:还有:显示您的代码!@RAnders00它运行良好,但我在终端上发现了这些错误,现在我如何通过仅在某些特定机器上获得这些错误来纠正。THnx您是否使用WebView?在这种情况下,您必须在加载页面之前将WebView与场景和舞台关联起来。以下是我所做的一些研究:还有:显示您的代码!@RAnders00它运行良好,但我在终端上遇到了这些错误,现在我如何通过仅在某些特定机器上获得这些错误来纠正。Thnx