https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
t

Takeshi Hagikura

11/20/2023, 3:19 PM
Anyone know if it's possible to include JBR as part of Compose Desktop app's distribution? I couldn't find if it's possible reliably.
a

Alexander Maryanovsky

11/20/2023, 3:41 PM
The packaging tasks should use the JRE pointed to by JAVA_HOME (when run from the command line).
t

Takeshi Hagikura

11/20/2023, 3:59 PM
Sounds great, thanks!
I couldn't package a desktop Compose app using one of the JBR. Filed https://github.com/JetBrains/JetBrainsRuntime/issues/256. I hope I'm not doing something wrong steps to package
a

Alexander Maryanovsky

11/20/2023, 5:53 PM
It’s not likely to be a bug.
m

Michael Paus

11/20/2023, 8:04 PM
You can use a normal JDK which contains all the tools for packaging and define the JRE you want to bundle with your app separately here:
Copy code
compose.desktop {
    application {
        mainClass = "MainKt"
        javaHome = JAVA_PACKAGE_HOME
        ...
where JAVA_PACKAGE_HOME could be pointing to your JBR.
thank you color 2
a

Alexander Maryanovsky

11/20/2023, 8:23 PM
My app is packaging with JBR without setting
javaHome
in
application
. I just have this in IDEA:
But setting
javaHome
is probably the more robust way.
t

Takeshi Hagikura

11/21/2023, 10:57 AM
Thanks. Hmm, but when I set the JAVA_HOME as the directory as the Oracle JDK instal path and setting the
javaHome
as the JBR in Android Studio,
Copy code
compose.desktop {
    application {
        mainClass = "MainKt"
        javaHome = "/Applications/Android_Studio_Preview_iguana_canary13.app/Contents/jbr/Contents/Home/"
        ...
packaging from the command line still no luck for me.
./gradlew :desktop:packageDistributionForCurrentOS
Copy code
* What went wrong:
Execution failed for task ':desktopApp:checkRuntime'.
> Failed to check JDK distribution: 'jpackage' is missing
  JDK distribution path: /Applications/Android_Studio_Preview_iguana_canary13.app/Contents/jbr/Contents/Home
a

Alexander Maryanovsky

11/21/2023, 11:00 AM
Try a standalone JBR installation maybe
For me
~/Library/Java/JavaVirtualMachines/jbr-17.0.9-1/Contents/Home/bin
does have the
jpackage
and
jlink
binaries
The JBR that comes bundled with Android Studio could have those binaries stripped
t

Takeshi Hagikura

11/21/2023, 11:49 AM
This is where standalone JBR can be downloaded, correct? https://github.com/JetBrains/JetBrainsRuntime/releases Tried jbr_jcef-17.0.8.1-osx-aarch64-b1059.3.pkg, but it doesn't seem to have
jlink
and
jpackage.
Copy code
* What went wrong:
Execution failed for task ':desktopApp:checkRuntime'.
> Failed to check JDK distribution: 'jlink', 'jpackage' are missing
  JDK distribution path: /Library/Java/JavaVirtualMachines/jbr_jcef-17.0.8.1-osx-aarch64-b1059.3/Contents/Home
a

Alexander Maryanovsky

11/21/2023, 11:50 AM
Also in IDEA -> File -> Project Structure -> SDKs -> Plus button
t

Takeshi Hagikura

11/21/2023, 12:31 PM
Ah thanks. I used Android Studio. The JBR downloaded from IDEA has
jlink
and
jpackage.
Hmm, but the app built with
./gradlew :desktopApp:packageDistributionForCurrentOS
or
./gradlew :desktopApp:runDistributable
doesn't seem to have JBR available.
JBR.isAvailable()
returns false
a

Alexander Maryanovsky

11/21/2023, 12:33 PM
What’s
JBR.isAvailable()
? It returning false seems to be a contradiction
t

Takeshi Hagikura

11/21/2023, 12:36 PM
I'm trying to use DecoratedWindow in jewel. And it seems to check the availability of JBR by calling JBR.isAvailable.
a

Alexander Maryanovsky

11/21/2023, 12:40 PM
print
System.getProperty("java.vendor")
t

Takeshi Hagikura

11/21/2023, 12:52 PM
Hmm, it shows "Oracle Corporation" I made sure
javaHome
is set to the downloaded path to JBR. Setting JAVA_HOME to the directory results in the same
Copy code
compose.desktop {
    application {
        mainClass = "MainKt"
        javaHome = "/Users/thagikura/Library/Java/JavaVirtualMachines/jbrsdk-17.0.9/Contents/Home"
m

Michael Paus

11/22/2023, 10:29 AM
The JBRs from https://github.com/JetBrains/JetBrainsRuntime/releases do indeed not contain jpackage and jlink and thus cannot be used.
t

Takeshi Hagikura

11/25/2023, 1:00 PM
It may be strange that JBRs on GitHub don't have jpackage and jlink, but somehow I managed to bundle JBR in the packaged app using the JBR installed from Intellij IDEA. Thanks both!
m

Michael Paus

11/25/2023, 1:42 PM
Yes, that once happened to me accidentally. Therefore I was surprised that the JBRs I examined either did not contain jpackage/jlink or, if the do contain it, it does not work. Does the DecoratedWindow in jewel now work with this?
By the way, the JBR in
Copy code
IntelliJ IDEA 2023.3 Beta (Community Edition)
Build #IC-233.11799.67, built on November 22, 2023
Runtime version: 17.0.9+7-b1087.7 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.1.1
does not seem to contain jpackage/jlink. Which version did you use?
t

Takeshi Hagikura

11/25/2023, 2:04 PM
I used the JBR installed by navigating to
File -> Project Structure -> SDKs -> Plus button
from Intellij IDEA IDEA version
Copy code
IntelliJ IDEA 2023.2.5 (Community Edition)
Build #IC-232.10227.8, built on November 9, 2023
Runtime version: 17.0.9+7-b1000.46 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 10
Metal Rendering is ON
Registry:
    debugger.new.tool.window.layout=true
    ide.experimental.ui=true
installed JBR version
17.0.9 (JetBrains s.r.o. 17.0.9+7-b1087.7)
m

Michael Paus

11/25/2023, 4:11 PM
Ahhh, that worked. The packaged application reports:
Copy code
java.vm.name: OpenJDK 64-Bit Server VM
java.runtime.version: 17.0.9+7-b1087.7
os.name: Mac OS X
os.arch: x86_64
java.vendor: JetBrains s.r.o.
Is this runtime now also compatible with Jewel? I haven’t had the time to try that yet.
t

Takeshi Hagikura

11/25/2023, 4:24 PM
Yes, jewel worked with the packaged Compose desktop app in Mac.
🙏 1