java应用程序错误_我想运行应用程序时出现Java FX错误

我尝试使用javaFx构建一个Windows应用程序,当我尝试运行该应用程序时,它给了我这个。

ant -f D:\\java\\NetBeansProjects\\Login2 jfxsa-run init: Deleting:

D:\java\NetBeansProjects\Login2\build\built-jar.properties deps-jar:

Updating property file:

D:\java\NetBeansProjects\Login2\build\built-jar.properties Compiling 1

source file to D:\java\NetBeansProjects\Login2\build\classes compile:

Deleting directory D:\java\NetBeansProjects\Login2\dist\lib Copying 1

file to D:\java\NetBeansProjects\Login2\dist\lib Detected JavaFX Ant

API version 1.3 Launching task from D:\Program Files

(x86)\Java\jdk1.8.0_161\jre\..\lib\ant-javafx.jar

Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.

Please set manifest.custom.codebase property to override the current default non-secure value '*'. Launching task from

D:\Program Files (x86)\Java\jdk1.8.0_161\jre\..\lib\ant-javafx.jar No

base JDK. Package will use system JRE. No base JDK. Package will use

system JRE. jfx-deployment-script: jfx-deployment: jar: Copying 13

files to D:\java\NetBeansProjects\Login2\dist\run1325232323

jfx-project-run: Executing

D:\java\NetBeansProjects\Login2\dist\run1325232323\Login2.jar using

platform D:\Program Files (x86)\Java\jdk1.8.0_161\jre/bin/java

Exception in Application start method

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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)

at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)

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: Exception in Application start method

at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.NullPointerException: Location is required.

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)

at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)

at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)

at login2.Login2.start(Login2.java:22)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)

at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)

at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)

at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)

at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)

... 1 more Exception running application login2.Login2 Java Result: 1

Deleting directory D:\java\NetBeansProjects\Login2\dist\run1325232323

jfxsa-run: BUILD SUCCESSFUL (total time: 4 seconds)

FXMLDocumentController.java:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package login2;

import java.net.URL;

import java.util.ResourceBundle;

import javafx.event.ActionEvent;

import javafx.fxml.FXML;

import javafx.fxml.Initializable;

import javafx.scene.control.Label;

/**

*

* @author IULIAN-DANIELGLAVAN

*/

public class FXMLDocumentController implements Initializable {

@FXML

private Label label;

@FXML

private void handleClose(ActionEvent event) {

System.exit(0);

}

@Override

public void initialize(URL url, ResourceBundle rb) {

// TODO

}

}

Login.java:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package login2;

import javafx.application.Application;

import javafx.fxml.FXMLLoader;

import javafx.scene.Parent;

import javafx.scene.Scene;

import javafx.stage.Stage;

/**

*

* @author IULIAN-DANIELGLAVAN

*/

public class Login2 extends Application {

@Override

public void start(Stage stage) throws Exception {

Parent root = FXMLLoader.load(getClass().getResource("/FXMLDocument.fxml"));

Scene scene = new Scene(root);

stage.setScene(scene);

stage.show();

}

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

launch(args);

}

}

FXMLDocument.fxml:

我将jfoenix.jar放在库中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值