Thread
#multiplatform
    s

    Shannon Duncan

    1 year ago
    Question about multiplatform compiling the JVM jar. I know we need to include the stdlibs to use the jar directly in the JVM, however the instructions to include that are not very clear. I've found myriad of stack overflows but none of them using the kotlin dsl gradle. One promising post suggested adding
    compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
    however I don't know where in the build.gradle.kts file to put it. When running the jar in JVM right now I get the error :
    java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
    w

    william

    1 year ago
    how are you building the jar right now? also what plugins do you have applied to the JVM module?
    s

    Shannon Duncan

    1 year ago
    Here is the current gradle file:
    plugins {
        kotlin("multiplatform") version "1.4.31"
    }
    
    group = "com.company.id"
    version = "0.0.2-SNAPSHOT"
    
    repositories {
        mavenCentral()
    }
    
    kotlin {
        jvm() {
          withJava()
    
        }
        macosX64("native") {
            binaries {
                framework {
                    baseName = "LRNB"
                }
                sharedLib {
                    baseName = "LRNB"
                }
            }
        }
    
        sourceSets {
            val commonMain by getting
            val commonTest by getting {
                dependencies {
                    implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
                    implementation("org.jetbrains.kotlin:kotlin-test-common")
                }
            }
            val nativeMain by getting {
    //            kotlin.srcDir("src/nativeMain/kotlin")
                dependsOn(commonMain)
            }
            val nativeTest by getting
            val jvmMain by getting {
                dependsOn(commonMain)
    
            }
            val jvmTest by getting {
              dependencies {
                implementation("junit:junit:4.12")
                implementation("org.jetbrains.kotlin:kotlin-test-junit")
              }
            }
        }
    }
    Has anyone else ran into this problem before? I figured compiling a jar with the required dependencies would be fairly straight forward 😞
    I think I got this to work with a shadow jar, now it’s just getting java to actually see my classes… 😞
    Kotlin sees them fine out of the Jar but java pffft nope.
    Ended up having to extract stuff from the Jar. Probably something in my lack of experience with Java itself.