gpt4 book ai didi

gradle - NoClassDefFoundError GradleBuild智能

转载 作者:行者123 更新时间:2023-12-03 03:27:38 25 4
gpt4 key购买 nike

我使用Gradle构建一个jar。我正在使用Intellij和Java 1.8,并且在Intellij环境中运行它时一切似乎都很好,但是当我想启动jar时,出现以下错误:

Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/scene/control/skin/BehaviorSkinBase
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at org.controlsfx.control.PropertySheet.createDefaultSkin(PropertySheet.java:254)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.scene.control.skin.BehaviorSkinBase
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 67 more
Exception running application de.informatik.gitlab2.itv.Main

有两个外部依赖项(controlsfx和jdom2)通过gradle构建文件中的maven进行了云化。

这是使用以下命令的build.gradle文件:
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
libs
}
dependencies{
testCompile group: 'junit', name: 'junit', version: '4.12

// https://mvnrepository.com/artifact/org.jdom/jdom
libs group: 'org.jdom', name: 'jdom', version: '2.0.0'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
libs group: 'org.controlsfx', name: 'controlsfx', version: '8.40.14'

configuration.compile.extendsFrom(configurations.libs)
}
jar {
manifest {
attributes 'Main-Class': 'de.informatik.gitlab2.itv.Main'
}
from {
configurations.libs.collect { it.isDirectory() ? it : zipTree(it) }
}
}

编辑

添加后
compile group: 'net.java.openjfx.backport', name: 'openjfx-78-backport-compat', version: '1.8.0.1'

进入build.gradle会发生此错误:
Exception in Application start method
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: com/sun/javafx/scene/control/skin/BehaviorSkinBase
at org.controlsfx.control.PropertySheet.createDefaultSkin(PropertySheet.java:254)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Scene.doCSSPass(Unknown Source)
at javafx.graphics/javafx.scene.Scene.access$3500(Unknown Source)
at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/scene/control/skin/BehaviorSkinBase
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at org.controlsfx.control.PropertySheet.createDefaultSkin(PropertySheet.java:254)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.superProcessCSSImpl(Unknown Source)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.superProcessCSS(Unknown Source)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Unknown Source)
at javafx.graphics/javafx.scene.Parent.access$400(Unknown Source)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
at javafx.graphics/javafx.scene.Scene.doCSSPass(Unknown Source)
at javafx.graphics/javafx.scene.Scene.preferredSize(Unknown Source)
at javafx.graphics/javafx.scene.Scene$2.preferredSize(Unknown Source)
at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(Unknown Source)
at javafx.graphics/javafx.stage.Window$12.invalidated(Unknown Source)
at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
at javafx.base/javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
at javafx.graphics/javafx.stage.Window.setShowing(Unknown Source)
at javafx.graphics/javafx.stage.Window.show(Unknown Source)
at javafx.graphics/javafx.stage.Stage.show(Unknown Source)
at de.uniwuerzburg.informatik.gitlab2.itv.Main.start(Main.java:35)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.scene.control.skin.BehaviorSkinBase
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 67 more
Exception running application de.informatik.gitlab2.itv.Main

EDIT2
我已经编辑了build.gradle文件:
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()

}

dependencies {

//
// https://mvnrepository.com/artifact/org.jdom/jdom
compile (
[group: 'org.jdom', name: 'jdom', version: '2.0.0'],
[group: 'org.controlsfx', name: 'controlsfx', version: '8.40.14'],
[group: 'net.java.openjfx.backport', name: 'openjfx-78-backport-compat', version: '1.8.0.1']
)
testCompile group: 'junit', name: 'junit', version: '4.12'
}

mainClassName = 'de.informatik.gitlab2.itv.Main'

jar {
manifest {
attributes( 'Main-Class': 'de.informatik.gitlab2.itv.Main',
'Class-Path' : configurations.compile.collect{ it.getName() }.join(''))
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

在完成干净的Gradle构建之后,这是MANIFEST.MF的代码
Manifest-Version: 1.0
Class-Path: jdom-2.0.0.jarcontrolsfx-8.40.14.jaropenjfx-78-backport-co
mpat-1.8.0.1.jar
Main-Class: de.informatik.gitlab2.itv.Main

这是 jar 的结构:
...
css
de
fxml
impl
java
javax
lang
META-INF
netscape
nodes
org
sun
controlsfx.properites

我的两个依赖项位于der文件夹“org”中。不应在 list 中使用org / ...作为类路径吗?并且MANIFEST.MF中的不同依赖项之间没有空格是一个错误,如果我怎么解决呢?

从cmd运行时的异常与上面相同:
Exception in Application start method
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: com/sun/javafx/scene/control/skin/BehaviorSkinBase
at org.controlsfx.control.PropertySheet.createDefaultSkin(PropertySheet.java:254)

最佳答案

com.sun.javafx.scene.control.skin.BehaviorSkinBase类属于

JavaFX 78 Backport兼容性库»1.8.0.1

请在您的build.gradle文件中添加以下gradle依赖项:

编译组:'net.java.openjfx.backport',名称:'openjfx-78-backport-compat',版本:'1.8.0.1'

引用:https://mvnrepository.com/artifact/net.java.openjfx.backport/openjfx-78-backport-compat/1.8.0.1

关于gradle - NoClassDefFoundError GradleBuild智能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48445077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com