https://kotlinlang.org logo
i

igor.wojda

07/03/2023, 5:40 PM
Hello I am not sure where to start , but I am looking for a way to run Kotlin code in form of some kind of an app on Windows. Unfortunately this machine does not have Java installed, so I wonder if any kond of workaround is possible. (the app is communicating with REAT APIs and establishing SSH sessions, so I believe it has to be native app rather than "browser JS app") What options do we have here to have standalone app? • Is it possible to build Kotlin app in from of
exe
file running on windows and bundle everything (Kotlin SDK, Java?) entire Kotlin & Java SDKs inside this bundle to un the app even if Java is not installed in the system? • Or would it be better to compile Kotlin to JS and pack it together with some kind of JS runtime (which?)? I would appreciate any feedback and ideas on this
j

Jeff Lockhart

07/03/2023, 5:44 PM
Kotlin/Native compiles to native binaries, including .exe on Windows. You could use Ktor client in Kotlin/Native.
i

igor.wojda

07/03/2023, 5:47 PM
Any open source project that can present this sample use case? Can exe be compiled on MacOS?
h

hfhbd

07/03/2023, 5:48 PM
You can also bundle the JVM runtime, like Intelij does.
l

Landry Norris

07/03/2023, 5:57 PM
Note that Kotlin/Native, especially on Windows may be missing important libraries. You can always use cinterop to call into Windows C apis, but don't expect to be able to use Compose for example from K/N.
r

Robert Jaros

07/03/2023, 5:57 PM
I think using ssh from kotlin native would be a challenge. I would go with bundled JVM or Kotlin/JS and Electron.
s

sciack

07/04/2023, 12:53 AM
With Java 17 there is jpackage that create redistributable runtime application for different environment: https://www.baeldung.com/java14-jpackage
There should be also gradle/maven plugin for it
a

Adam S

07/04/2023, 7:49 AM
is it possible to use Docker, Hyper-V, or WSL on the Windows machine?
no red 1
s

Stefan Oltmann

07/16/2023, 12:00 PM
Any open source project that can present this sample use case? Can exe be compiled on MacOS?
Yes. Windows binary config: https://github.com/Ashampoo/kim/blob/2b35aecd4a8611faf79e5a004af97c8ad5662508/build.gradle.kts#L132C1-L132C1 macOS binary config: https://github.com/Ashampoo/kim/blob/2b35aecd4a8611faf79e5a004af97c8ad5662508/build.gradle.kts#L193C6-L193C6 Main method for both: https://github.com/Ashampoo/kim/blob/main/src/posixMain/kotlin/com/ashampoo/kim/main.kt If you stay with POSIX API and only use Kotlin Multiplatform dependencies that include native you will be fine. AFAIK Ktor has full multiplatform support, so your REST client should work without Java. Things change if you need also an UI with Compose. In that case you need to bundle a JVM.