Good morning, everyone. I'm having a problem, I've already created several .jar and never had this kind of problem, but with this one something isn't working right.
I created a .Jar of my java program, I use IntelliJ, Gradle and JavaFX in the project. In the IDE everything works perfectly, but in the .Jar I got the following error: Could not find or load main class com.infolance.Main
My build.gradle
plugins {
id 'java'
id 'application'
id '.openjfx.javafxplugin' version "0.0.13"
id '.beryx.jlink' version '2.12.0'
id 'com.gluonhq.gluonfx-gradle-plugin' version '1.0.19'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
group 'com.infolance'
version '1.6.4'
sourceCompatibility = "17"
repositories {
mavenCentral()
maven {
url ''
}
flatDir {
dirs 'libs'
}
}
dependencies {
implementation '.jetbrains:annotations:24.0.0'
testImplementation '.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly '.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation 'com.fazecast:jSerialComm:2.9.2'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.1'
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0'
implementation '.update4j:update4j:1.5.9'
compileOnly '.projectlombok:lombok:1.18.26'
annotationProcessor '.projectlombok:lombok:1.18.26'
implementation '.apache.httpcomponents:httpclient:4.5.13'
implementation 'com.github.wendykierp:JTransforms:3.0'
implementation '.apachemons:commons-math3:3.6.1'
implementation 'io.github.typhon0:AnimateFX:1.2.4'
implementation 'com.jfoenix:jfoenix:9.0.1'
implementation 'com.gluonhq:charm-glisten:6.2.3'
implementation 'com.gluonhq:glisten-afterburner:2.1.0'
implementation 'io.github.mkpaz:atlantafx-base:2.0.1'
testImplementation '.assertj:assertj-core:3.24.2'
implementation 'fr.brouillard.oss:cssfx:11.5.1'
implementation '.kordamp.ikonli:ikonli-javafx:12.3.1'
implementation '.kordamp.ikonli:ikonli-material2-pack:12.3.1'
implementation '.kordamp.ikonli:ikonli-fontawesome-pack:12.3.1'
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11'
implementation 'mysql:mysql-connector-java:8.0.33'
testImplementation 'com.h2database:h2:1.3.148'
testCompileOnly '.projectlombok:lombok:1.18.26'
testAnnotationProcessor '.projectlombok:lombok:1.18.26'
}
test {
systemProperty "file.encoding", "UTF-8"
useJUnitPlatform()
}
javafx {
version = "20.0.2"
modules = ['javafx.swing', 'javafx.graphics', 'javafx.fxml', 'javafx.media', 'javafx.controls', 'javafx.web']
}
application {
mainClass.set("com.infolance.Main")
}
shadowJar {
archiveClassifier.set('')
manifest {
attributes 'Main-Class': 'com.infolance.Main'
}
}
jar {
from {
sourceSets.main.output
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes 'Main-Class': 'com.infolance.Main'
}
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'Infolance'
}
moduleName = 'com.infolance'
mainClass = 'com.infolance.Main'
}
gluonfx {
attachConfig {
version = "4.0.18"
services 'display', 'lifecycle', 'statusbar', 'storage'
}
}
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Here is the .jar structure opened in WinRar:
And here she is in the IDE:
I tried adding the -cp command to force initialization and it didn't work either, the -jar always returns the same problem. The build mode I'm using is Gradle/build/build:
A comment about the project that may be relevant, I created it copied from another project of mine and renamed the packages and class. and I made all the modifications to create a new project from this one already ready, I do not know if this may have affected the classpath.