原创

调试Jpackage可执行文件

温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

i'm using gradle and created a jpackage task. But the executable file doesn't run correctly, i want to see what is happening in console. For that my researchs came to the conclusion that I should use --win-console in jpackage configuration. But results in:

enter image description here

this is my build.gradle:

buildscript {
    ext.gradle_version = "7.1.1"
}

plugins {
    id "java"
    id "application"
    id "org.javamodularity.moduleplugin" version "1.8.12"
    id "org.openjfx.javafxplugin" version "0.0.13"
    id "org.beryx.jlink" version "2.25.0"
}

group "com.webkriativa.mypackage"
version "0.5"

var simpleitkVersion = "2.3.1"
var simpleitkLibPath = "libs/SimpleITK-" + simpleitkVersion
var simpleitkJarPath = simpleitkLibPath + "/simpleitk-" + simpleitkVersion + ".jar"
var lwjglNativesPath = "libs/lwjgl";
var dcm4chePath = "libs/dcm4che-5.31.2";
var openCVNativesWindowsPath = "libs/dcm4che-5.31.2/lib/windows-x86-64"
project.ext.lwjglVersion = "3.3.3"
project.ext.lwjglNatives = "natives-windows"

repositories {
    mavenCentral()
    maven {
        url = uri("https://maven.scijava.org/content/repositories/public/")
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = "UTF-8"
}

application {
    mainModule = "com.webkriativa.mypackage"
    mainClass = "com.webkriativa.mypackage.MRETest"
}

javafx {
    version = "17.0.6"
    modules = ["javafx.controls", "javafx.fxml", "javafx.graphics"]
}

dependencies {
    //a lot of things here
}

jar {
    manifest {
        attributes "Main-Class" : "com.webkriativa.mypackage.MRETest"
    }

    duplicatesStrategy = "exclude"

}

tasks.jpackageImage.doLast {
    copy {
        from("src/main/resources")
        into("$buildDir/jpackage/$project.name/src/main/resources")
    }
    copy {
        from simpleitkLibPath
        into("$buildDir/jpackage/$project.name/runtime/bin")
        include '**/*.dll'
    }
    copy {
        from lwjglNativesPath
        into("$buildDir/jpackage/$project.name/runtime/bin")
    }
    copy {
        from dcm4chePath
        into("$buildDir/jpackage/$project.name/runtime/bin")
    }
    copy{
        from 'src'
        into("$buildDir/jpackage/$project.name")
        include 'run-noah.bat'
    }
}

jlink{
    jpackage {
        if (org.gradle.internal.os.OperatingSystem.current().windows) {
            installerOptions += ['--win-per-user-install', '--win-menu', '--win-shortcut', '--win-menu-group', '--win-dir-chooser', '--win-console']
        }
    }
}

run {
    jvmArgs = ['-Djava.library.path="' + lwjglNativesPath + ';' + openCVNativesWindowsPath + ';' + simpleitkLibPath + '"', '--add-opens', 'java.desktop/javax.imageio.stream=dcm4che.imageio.opencv',
               '--add-opens', 'java.base/java.io=dcm4che.imageio.opencv', '-Dorg.lwjgl.util.Debug=true', '-Dorg.lwjgl.util.DebugLoader=true']
}

I know the problem is related to LWJGL (opengl wrapper), because it was working until i added this lib. So it isnt a javafx/simpleitk/dcm4che problem.

正文到此结束
热门推荐
本文目录