Gradle jpackage creating unrunnable application Code Answer

I am trying to run jpackage with a bare bones Gradle JavaFX application mostly to try things out. There is nothing special about it, its the IntelliJ JavaFX sample with Gradle added in. The application runs fine with gradlew clean build run. However, when creating a package with gradlew jpackage the resulting exe crashes instantly and creates an hs_err_pid.

# A fatal error has been detected by the Java Runtime Environment:
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000000000000, pid=1132, tid=15340
# JRE version:  (15.0.2+10) (build )
# Java VM: OpenJDK 64-Bit Server VM (15.0.2+10, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  0x0000000000000000

See full output here:

I’ve tried the answers on a similar question but they did not work.

  • Copying zip.dll from {app}runtimebin to {app}
  • Trying other JDKs
    • AdoptOpenJDK 11
    • AdoptOpenJDK 14
    • AdoptOpenJDK 15
    • BellSoft Liberica JDK 15

build.gradle looks like this

// Setup Gradle
plugins {
    id "application"
    id "org.beryx.runtime" version "1.12.2"
    id "org.openjfx.javafxplugin" version '0.0.9'

repositories {

// Setup application, dependencies
group = "io.mattw.sample"
sourceCompatibility = 15
targetCompatibility = 15

application {
    mainClassName = "io.mattw.sample.Main"

javafx {
    version = 15
    modules = ["javafx.base", "javafx.controls", "javafx.fxml"]

dependencies {


// Setup release
runtime {
    addOptions("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")

tasks.runtime.doLast {
    copy {


When running the exe with WinDbg (preview), I get the following output. Possibly relevant that I have Java 8 installed normally though I’d expect it to use the bundled SDK and not the systems.

Microsoft (R) Windows Debugger Version 10.0.21306.1007 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxgradle-test-javafx.exe

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`995d0000 00007ff6`9963f000   image00007ff6`995d0000
ModLoad: 00007ffc`36450000 00007ffc`36646000   ntdll.dll
ModLoad: 00007ffc`35320000 00007ffc`353dd000   C:WINDOWSSystem32KERNEL32.DLL
ModLoad: 00007ffc`33d90000 00007ffc`34059000   C:WINDOWSSystem32KERNELBASE.dll
ModLoad: 00007ffc`36210000 00007ffc`363b0000   C:WINDOWSSystem32USER32.dll
ModLoad: 00007ffc`33d30000 00007ffc`33d52000   C:WINDOWSSystem32win32u.dll
ModLoad: 00007ffc`346f0000 00007ffc`3471a000   C:WINDOWSSystem32GDI32.dll
ModLoad: 00007ffc`343a0000 00007ffc`344ab000   C:WINDOWSSystem32gdi32full.dll
ModLoad: 00007ffc`33c90000 00007ffc`33d2d000   C:WINDOWSSystem32msvcp_win.dll
ModLoad: 00007ffc`33b90000 00007ffc`33c90000   C:WINDOWSSystem32ucrtbase.dll
ModLoad: 00007ffc`35ac0000 00007ffc`36202000   C:WINDOWSSystem32SHELL32.dll
(4ad0.33e0): Break instruction exception - code 80000003 (first chance)
00007ffc`36520670 cc              int     3
0:000> g
ModLoad: 00007ffc`355c0000 00007ffc`355f0000   C:WINDOWSSystem32IMM32.DLL
ModLoad: 00007ffc`34ba0000 00007ffc`34c4e000   C:WINDOWSSystem32shcore.dll
ModLoad: 00007ffc`35a20000 00007ffc`35abe000   C:WINDOWSSystem32msvcrt.dll
ModLoad: 00007ffc`34840000 00007ffc`34b96000   C:WINDOWSSystem32combase.dll
ModLoad: 00007ffc`35720000 00007ffc`3584b000   C:WINDOWSSystem32RPCRT4.dll
ModLoad: 00007ffc`11d50000 00007ffc`11d68000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinjli.dll
ModLoad: 00007ffc`224e0000 00007ffc`22590000
ModLoad: 00007ffc`22cb0000 00007ffc`22cc9000   C:WINDOWSSYSTEM32VCRUNTIME140.dll
ModLoad: 00007ffc`34c50000 00007ffc`34cfc000   C:WINDOWSSystem32ADVAPI32.dll
ModLoad: 00007ffc`35520000 00007ffc`355bc000   C:WINDOWSSystem32sechost.dll
ModLoad: 00007ffc`10080000 00007ffc`10095000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinvcruntime140.dll
ModLoad: 00007ffb`f76b0000 00007ffb`f774b000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinmsvcp140.dll
ModLoad: 00007ffb`a5030000 00007ffb`a5bbf000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinserverjvm.dll
ModLoad: 00007ffc`34630000 00007ffc`34638000   C:WINDOWSSystem32PSAPI.DLL
ModLoad: 00007ffc`1ff10000 00007ffc`1ff19000   C:WINDOWSSYSTEM32WSOCK32.dll
ModLoad: 00007ffc`32a70000 00007ffc`32a7a000   C:WINDOWSSYSTEM32VERSION.dll
ModLoad: 00007ffc`261f0000 00007ffc`26217000   C:WINDOWSSYSTEM32WINMM.dll
ModLoad: 00007ffc`35870000 00007ffc`358db000   C:WINDOWSSystem32WS2_32.dll
ModLoad: 0000014c`22330000 0000014c`2239b000   C:WINDOWSSystem32ws2_32.DLL
ModLoad: 00007ffc`32a30000 00007ffc`32a42000   C:WINDOWSSYSTEM32kernel.appcore.dll
ModLoad: 00007ffc`2acf0000 00007ffc`2acfa000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinjimage.dll
ModLoad: 00007ffc`22590000 00007ffc`22774000   C:WINDOWSSYSTEM32DBGHELP.DLL
ModLoad: 00007ffc`21be0000 00007ffc`21c0c000   C:WINDOWSSYSTEM32dbgcore.DLL
ModLoad: 00007ffc`34060000 00007ffc`340e0000   C:WINDOWSSystem32bcryptPrimitives.dll
ModLoad: 00007ffc`09f50000 00007ffc`09f75000   C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinjava.dll
(4ad0.30c4): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
0000014c`23890969 8b06            mov     eax,dword ptr [rsi] ds:00000000`00000000=????????
0:004> g
(4ad0.30c4): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** WARNING: Unable to verify checksum for C:GitHubgradle-test-javafxbuildjpackagegradle-test-javafxruntimebinjimage.dll
00000000`00000000 ??              ???
0:004> g
00007ffc`364ecba4 c3              ret


Combining both answers and waiting a bit for things to update fixed the issue for me.

  1. Upgraded Gradle to 7.0-RC-1 which has support for JDK 16 in
  1. Downloaded and using Liberica JDK 16 (@FlickIt)
  2. Using the addModules() fix for Liberica in the build.gradle (@Jorn Vernee)
runtime {
    addOptions("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")
    addModules("javafx.base", "javafx.controls", "javafx.fxml", "", "javafx.web")

Running jpackage in Gradle now produces a runnable JavaFX exe without needing to copy dlls!

If your application has more than just JavaFX as a dependency, change #3 to ALL-MODULE-PATH. It makes the packaged files/app much larger but will allow it to run.

runtime {
    addOptions("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji