的InvocationTargetException基本JavaFX应用程序所造成的空指针
问题描述:
我想按照这个JavaFX的3D tutorial,但是我得到以下错误(我通过安装32位的GTK2包和库清理几个早期的错误),但这个问题不似乎是这样。我在网上找不到任何相同的错误。的InvocationTargetException基本JavaFX应用程序所造成的空指针
注:我没有一个FXML文件(我不认为我需要一个为我设定了这一切的代码)
运行Ubuntu 16.04.3基本OS洛基
错误信息:
Gtk-Message: Failed to load module "pantheon-filechooser-module"
Gtk-Message: Failed to load module "gail"
Gtk-Message: Failed to load module "atk-bridge"
Gtk-Message: Failed to load module "canberra-gtk-module"
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.NullPointerException
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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
代码:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.PointLight;
import javafx.scene.Scene;
import javafx.scene.shape.Box;
import javafx.stage.Stage;
public class GraphicsApplication extends Application {
public void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Box box = new Box(100,100,100);
box.setTranslateX(150);
box.setTranslateY(100);
PointLight light = new PointLight();
light.setTranslateX(300);
light.setTranslateY(350);
light.setTranslateZ(200);
PerspectiveCamera camera = new PerspectiveCamera();
camera.setTranslateX(100);
camera.setTranslateY(-50);
camera.setTranslateZ(300);
Group root = new Group(box, light);
Scene scene = new Scene(root, 400, 200, true);
scene.setCamera(camera);
primaryStage.setScene(scene);
primaryStage.setTitle("Super test 5000");
primaryStage.show();
}
}
这是完整的堆栈跟踪吗? –
是的,它们都不是来自我的代码: – ollie299792458