Im trying to build a jar file of my java 1.8 code using intellij. If im running the code in intelliy everything is ok, but when i build a gradle which doesnt produce any errors and try to start the jar in the cmd
i get the following error:
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)
Here is my build.gradle file :
version ‘1.0-SNAPSHOT’
apply plugin: ‘java’
apply plugin: ‘idea’
//apply plugin: ‘application’sourceCompatibility = 1.8
targetCompatibility = 1.8repositories {
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) } }
}
This gradle.build produces a MANIFEST.MF with:
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.uniwuerzburg.informatik.gitlab2.itv.Main
And the file structure of my jar after the build is :
…
css
de
fxml
impl
java
javax
lang
META-INF
netscape
nodes
org
sun
In the folder org are the two dependencies ControlsFX and JDOM
It looks like Its not getting the Class file(BehaviorSkinBase) at runtime which was present in compile time
My assumption is that there is something wrong with the ClassPath in the Manifest file. Is is normal that there are noch whitespaces between two different dependencies and why ist there no directory org/jdom in the classpath? If this is the Problem how can i solve it?