无法将模块添加到jpackage创建的应用程序中

时间:2020-07-14 00:36:27

标签: java ssl module jpackage

将我的jpackage创建的应用程序连接到websocket端点时遇到问题。通过我的IDE运行时协商的密码在生成的映像中不可用。看来我遇到了这里描述的问题:https://www.gubatron.com/blog/2019/04/25/solving-received-fatal-alert-handshake_failure-error-when-performing-https-connections-on-a-custom-made-jre-with-jlink/

我现在正尝试将jdk.crypto.cryptoki添加到我的jpackage中,但无法添加。

我首先尝试了

runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    jpackage {
        imageName = 'MyCorpDashboard'
        installerName = 'MyCorpInstaller'
        appVersion = '0.1.0'
        if(org.gradle.internal.os.OperatingSystem.current().windows) {
            jpackageHome = 'D:\\Java\\jdk-14' // Needs to be JDK 14
            installerType = 'exe'
            jvmArgs = ['-Djava.security.debug=access,stack',
                       '-Dhttps.protocols=SSLv2,TLSv1.2',
                       '-Djavax.net.debug=ssl:handshake:verbose'
                       '--add-modules', 'jdk.crypto.cryptoki']
            imageOptions = ['--win-console', '--icon','src/main/resources/com/mycorp/ui/dashboard/icon_wh.ico']
            installerOptions = ['--win-per-user-install',
                            '--win-dir-chooser',
                            '--win-menu',
                            '--win-shortcut',
                            '--vendor', 'My Corp']
        } else if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
            jpackageHome = '/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/' // Needs to be JDK 14
            imageOptions = ['--vendor', 'My Corp',
                            '--icon','src/main/resources/com/mycorp/ui/dashboard/icon_wh.icns']
        }
    }
}

但是得到

Error occurred during initialization of boot layer
java.lang.module.FindException: Module jdk.crypto.cryptoki not found

我也尝试过

compileJava {
    options.compilerArgs += ["--add-modules", "jdk.crypto.cryptoki"]
}

那也不起作用。

如何添加此模块,使其与我的应用程序打包在一起?

1 个答案:

答案 0 :(得分:0)

oi-发布后,我认为我现在可以在运行时(重新访问https://badass-runtime-plugin.beryx.org/releases/latest/之后)看到它

runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    modules = ['jdk.crypto.cryptoki']
    jpackage {
        imageName = 'MyCorpDashboard'
        installerName = 'MyCorpInstaller'
        appVersion = '0.1.0'
        if(org.gradle.internal.os.OperatingSystem.current().windows) {
            jpackageHome = 'D:\\Java\\jdk-14' // Needs to be JDK 14
            installerType = 'exe'
            jvmArgs = ['-Djava.security.debug=access,stack',
                       '-Dhttps.protocols=SSLv2,TLSv1.2',
                       '-Djavax.net.debug=ssl:handshake:verbose']
            imageOptions = ['--win-console', '--icon','src/main/resources/com/mycorp/ui/dashboard/icon_wh.ico']
            installerOptions = ['--win-per-user-install',
                            '--win-dir-chooser',
                            '--win-menu',
                            '--win-shortcut',
                            '--vendor', 'My Corp']
        } else if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
            jpackageHome = '/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home/' // Needs to be JDK 14
            imageOptions = ['--vendor', 'My Corp',
                            '--icon','src/main/resources/com/mycorp/ui/dashboard/icon_wh.icns']
        }
    }
}