Hi, I'm building my desktop app to an MSI but when...
# compose-desktop
g
Hi, I'm building my desktop app to an MSI but when I run the .exe, nothing happens (the executable just exits immediately). I suspect there are some dependencies missing from the installed files. My app uses
javafx
and my build.gradle.kts has these dependencies in it. If I rip out the
javafx
dependencies and associated code, the app installs and runs fine. 1) How can I package up my app to run with javafx?, and 2) is there a way to diagnose the running of the .exe issue (e.g. any diagnostics or logs to view)? build.gradle.kts excerpts:
Copy code
plugins {
    kotlin("jvm") version "1.4.30"
    id("org.jetbrains.compose") version "0.3.0"
    id("org.openjfx.javafxplugin") version "0.0.9"
}
...
javafx {
    modules("javafx.controls", "javafx.swing", "javafx.media")
}
Thanks!
o
maybe your JavaFX dependencies are not picked up by the plugin. I’d suggest to check with jpackage developers on how better identify the issue. Our Gradle plugin provides task
runDistributable
which could be helpful here.
g
Thanks! It seems, for debugging the exe, being able to run
jpackage
with the
--win-console
option might be useful (https://stackoverflow.com/a/64614660/5670695). How can I change the
jpackage
options used by the Gradle tasks? Note: for some reason,
runDistributable
fails to execute the app for me with:
Starting process 'command 'CorrectAppName.exe''. Working directory: C:\<correct path>\CorrectAppName Command: CorrectAppName.exe
CreateProcess error=2, The system cannot find the file specified
o
it could be signal of some native dll not found, like in https://github.com/openjfx/javafx-maven-plugin/issues/19. I'd suggest to add packaging required libs manually.
a
--win-console
can be specified like this:
Copy code
compose.desktop {
    application {
        nativeDistributions {
            windows {
                console = true
            }
        }
    }
}
Also you can check out the DSL reference here.
👍 1
As for the
runDistributable
error: could you try a newer build (e.g. 0.4.0-build180)? I remember fixing a similar issue some time ago.
g
Thanks @alexey.tsvetkov, @olonho. Updating to 0.4.0-build180 fixed the runDistributable 👍 That nativeDistribution DSL is just what I was looking for. FYI: I did manage to run jpackage myself and set --win-console and discovered the missing packages, which I've added to the build.gradle.kts as follows. I don't think I would have worked it out without having the win-console output.
Copy code
implementation("org.openjfx:javafx-controls:13")
    implementation("org.openjfx:javafx-swing:13")
    implementation("org.openjfx:javafx-media:13")

    // To resolve: java.lang.NoClassDefFoundError: "jdk/swing/interop/SwingInterOpUtils" when trying to jfxPanel.setScene()
    implementation(files("packaging-libs/jdk.unsupported.desktop-jdk15.jar"))
k
Copy code
java.lang.NoClassDefFoundError: "jdk/swing/interop/SwingInterOpUtils"
Im facing this issue @Graham Dean and I added
Copy code
implementation(files("packaging-libs/jdk.unsupported.desktop-jdk15.jar"))
but ig this jar isnt at my side so how to do it >
a
Have you tried adding
jdk.unsupported.desktop
module dependency?
Copy code
compose.desktop {
    application {
        nativeDistributions {
            modules("jdk.unsupported.desktop")
        }
    }
}
If that helps, I recommend reading this section of the docs https://github.com/JetBrains/compose-multiplatform/tree/master/tutorials/Native_distributions_and_local_execution#configuring-included-jdk-modules