2

我正在使用jpackage将jar文件转换为exe,其中exe文件由内部JRE提供。作为转换的结果,获得了良好的结果,JRE 重约 38.5 mb。

当我运行 exe 时,GUI 质量是普通 jar 的两倍!此外,新exe文件的窗口会自行增加。于是,就出现了非常奇怪的变化,好像exe文件在试图模仿一个window jar文件一样。我想指出我正在为 GUI 使用 libGdx。

比较

桌面毕业:

{
plugins { id 'org.beryx.runtime' version '1.8.4' }
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../android/assets"]

mainClassName = "com.iapp.chess.desktop.DesktopLauncher"
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
project.ext.assetsDir = new File("../android/assets")

task runGame(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
    debug = true
}

task dist(type: Jar) {
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
    destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist


dist.dependsOn classes

eclipse.project.name = appName + "-desktop"

runtime {
    options = ['--strip-debug',
               '--compress', '2',
               '--no-header-files',
               '--no-man-pages',
               '--strip-native-commands',
               '--vm', 'server']
    modules = ['java.base',
               'java.desktop',
               'jdk.unsupported']
    distDir = file(buildDir)

    jpackage {
        jpackageHome = 'C:\\Program Files\\Java\\jdk-17.0.2'
        mainJar = dist.archiveFileName.get()
        if (osName.contains('windows')) {
            imageOptions = ["--icon", file("../icons/icon.ico")]
        } else if (osName.contains('linux')) {
            imageOptions = ["--icon", file("../icons/icon.png")]
        } else if (osName.contains('mac')) {
            imageOptions = ["--icon", file("../icons/icon.icns")]
        }
    }
}

}

4

0 回答 0