How to include Java in this project and enable mixed development with both Java and Kotlin
04:50 10 Nov 2025

How to include Java in this project and enable mixed development with both Java and Kotlin.

I want to know how to use Java and Kotlin interoperably in a Kotlin Multiplatform Compose Desktop project, and how should I configure it in the gradle.kts file? The above is my gradle.kts file.

enter image description here enter image description here

import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.composeMultiplatform)
    alias(libs.plugins.composeCompiler)
    alias(libs.plugins.composeHotReload)
}

group = "com.sidnio.siyu.server.ui"
//version = "0.0.1-SNAPSHOT"


kotlin {
    jvm()
    sourceSets {
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodelCompose)
            implementation(libs.androidx.lifecycle.runtimeCompose)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
        jvmMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(libs.kotlinx.coroutinesSwing)

            // https://mvnrepository.com/artifact/org.jetbrains.compose.material/material-icons-extended-desktop
            implementation("org.jetbrains.compose.material:material-icons-extended-desktop:1.7.3")

            implementation("org.xerial:sqlite-jdbc:3.51.0.0")
        }
    }
}



compose.desktop {
    application {
        mainClass = "com.sidnio.siyu.server.ui.demo.MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "com.sidnio.siyu.server.ui.demo"
            packageVersion = "1.0.0"
        }
    }
}
kotlin-multiplatform compose-desktop