Thread
#multiplatform
    Dominaezzz

    Dominaezzz

    3 years ago
    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

    3 years ago
    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.
    Dominaezzz

    Dominaezzz

    3 years ago
    Thank you! 😊
    h0tk3y

    h0tk3y

    3 years ago
    Here's a snippet I use to run one the classes of a JVM target with a Gradle task:
    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
        )
    }
    r

    r4zzz4k

    3 years ago
    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