https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

Dominaezzz

01/08/2019, 6:24 PM
I'm trying to setup a multiplatform application project but I can't figure out how to (nicely) get the generated jar to execute it. In the native case there's
kotlin.targets.mingw.compilations.main.getBinary('EXECUTABLE', buildType)
to get the binary for execution. What is the jvm equivalent?
kotlin.targets.jvm.compilations.main.getJar('EXECUTABLE', buildType)
doesn't work 🙂.
Ah! Found it. It's
jvmJar.archivePath
or at least it's close enough.
Couldn't run the jar. I got
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
. Not sure how to add kotlin-runtime to classpath in this setup. 😞
r

r4zzz4k

01/09/2019, 7:30 AM
You should not just run one jar, but form claasspath based on runtime configuration from Gradle -- it would have your classes and your dependencies. I'll try to remember to get back to you as soon as I get to office, if you or someone else doesn't provide Gradle snippet to do in.
d

Dominaezzz

01/09/2019, 8:32 AM
Thank you! 😊
h

h0tk3y

01/09/2019, 11:09 AM
Here's a snippet I use to run one the classes of a JVM target with a Gradle task:
Copy code
task run(type: JavaExec) {
    main = 'com.my.entry.Point'
    def target = kotlin.targets.jvm
    def compilation = target.compilations.main

    classpath = files(
        compilation.runtimeDependencyFiles,
        compilation.output.allOutputs
    )
}
👍 2
r

r4zzz4k

01/09/2019, 11:32 AM
Yeah, I had something along those lines too. @Dominaezzz by the way, there is an issue for having this out of the box, you can follow it if you wish: https://youtrack.jetbrains.com/issue/KT-27273