我尝试使用gradle插件gradle-launch4j以及以下build.gradle配置生成exe:
plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'application'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
// lib via maven
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.15'
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.28.0'
}
jar {
manifest {
attributes 'Main-Class': 'Main'
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
application {
mainClassName = 'Main'
}
launch4j {
mainClassName = 'Main'
outfile = 'Gymnasium.exe'
icon = "${projectDir}/src/main/resources/view/img/icona.ico"
jreMinVersion = "1.8.0"
}
Exe已生成,但尝试运行,但无法启动。我注意到,如果我使用java -jar Gymnasium.exe命令从终端启动它,它将启动。 我的配置有问题吗?我试图搜索是否有人遇到类似问题,但没有找到任何东西。
注意:如果我尝试从Launch4j应用程序生成exe,那么它会完美运行。