我正在开发一个javafx应用程序,gradle wrapper
和gradle build
都成功完成。不幸的是,当我尝试gradle run
时,我收到以下错误:
失败:构建因异常而失败。
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
我知道它可能与jfxrt.jar有关。我错过了一个导入?
gradle -v
------------------------------------------------------------
Gradle 2.6
------------------------------------------------------------
Build time: 2015-08-10 13:15:06 UTC
Build number: none
Revision: 233bbf8e47c82f72cb898b3e0a96b85d0aad166e
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_51 (Oracle Corporation 25.51-b03)
OS: Mac OS X 10.10.4 x86_64
我的build.gradle文件:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
mainClassName = 'main.screens.ScreenFramework'
jar {
baseName = 'wfmgrG'
version = '0.1.0'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
运行gradle run --debug 2> gradlebug.txt
时,这是我的gradlebug.txt文件:
14:32:57.310 [ERROR] [system.err] Exception in Application start method
14:32:57.331 [ERROR] [system.err] java.lang.reflect.InvocationTargetException
14:32:57.332 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:32:57.333 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:32:57.333 [ERROR] [system.err] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:32:57.333 [ERROR] [system.err] at java.lang.reflect.Method.invoke(Method.java:497)
14:32:57.333 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
14:32:57.333 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
14:32:57.333 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:32:57.334 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:32:57.334 [ERROR] [system.err] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:32:57.334 [ERROR] [system.err] at java.lang.reflect.Method.invoke(Method.java:497)
14:32:57.335 [ERROR] [system.err] at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
14:32:57.335 [ERROR] [system.err] Caused by: java.lang.RuntimeException: Exception in Application start method
14:32:57.336 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
14:32:57.336 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
14:32:57.337 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl$$Lambda$50/1323468230.run(Unknown Source)
14:32:57.337 [ERROR] [system.err] at java.lang.Thread.run(Thread.java:745)
14:32:57.338 [ERROR] [system.err] Caused by: java.lang.NullPointerException
14:32:57.338 [ERROR] [system.err] at main.java.screens.ScreenFramework.start(ScreenFramework.java:39)
14:32:57.338 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
14:32:57.339 [ERROR] [system.err] at com.sun.javafx.application.LauncherImpl$$Lambda$53/292202963.run(Unknown Source)
14:32:57.339 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
14:32:57.339 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl$$Lambda$46/186276003.run(Unknown Source)
14:32:57.339 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
14:32:57.339 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl$$Lambda$48/963494156.run(Unknown Source)
14:32:57.339 [ERROR] [system.err] at java.security.AccessController.doPrivileged(Native Method)
14:32:57.340 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
14:32:57.341 [ERROR] [system.err] at com.sun.javafx.application.PlatformImpl$$Lambda$47/237061348.run(Unknown Source)
14:32:57.342 [ERROR] [system.err] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
14:32:57.342 [ERROR] [system.err] at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
14:32:57.342 [ERROR] [system.err] at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
14:32:57.342 [ERROR] [system.err] at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
14:32:57.343 [ERROR] [system.err] ... 1 more
14:32:57.348 [ERROR] [system.err] Exception running application main.java.screens.ScreenFramework
14:32:57.708 [ERROR] [org.gradle.BuildExceptionReporter]
14:32:57.708 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter]
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':run'.
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'command 'C:\Users\a51217\Downloads\jdk-8u51\bin\java.exe'' finished with non-zero exit value 1
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter]
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
14:32:57.709 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
调试堆栈跟踪太长,无法在此处发布。
答案 0 :(得分:0)
检查第39行的ScreenFramework类。这是由java.lang.NullPointerException引起的。
14:32:57.338 [ERROR] [system.err] Caused by: java.lang.NullPointerException
14:32:57.338 [ERROR] [system.err] at main.java.screens.ScreenFramework.start(ScreenFramework.java:39)