Hi All, is it possible to call native OS APIs from...
# compose-desktop
a
Hi All, is it possible to call native OS APIs from within a compose desktop app? E.g. when running on MacOS call some Apple Framework, when on Windows call a Windows API.
j
The easiest way to achieve this would be using JNI. The default configuration will deploy the desktop application as a JVM application, so you can use JNI with Kotlin. At the moment, this is probably the approach I'd utilize. For completeness, I'll also mention that you could try compiling your Compose Desktop app directly to native binaries, in which case you can use the Kotlin c-interop to work directly with the native platform APIs. I've seen a couple demos of that, but this is still fairly experimental and not publicly documented so it would require some legwork on your part if you wanted to pursue this approach.
a
yeah looks like it's an experimental feature, but allows to call native APIs: https://github.com/JetBrains/compose-jb/blob/master/experimental/examples/falling-balls-mpp/build.gradle.kts#L199
m
On the JVM there is JNI (old, built in and stable but not very convenient as it requires writing C or C++), JNA (more modern, like an FFI, you just write Java), JavaCPP (can bind direct to C++ APIs, most advanced) and the new kid on the block Panama (built in but only in the very latest JDKs and still in preview mode).