Hey everyone. I have been struggling to fix this issue. There’s a bug in my build.gradle.kts
that I can’t fix. I have tried implementing kotlin std lib, tried applying idea
and application
plugins but still nothing worked for me. Tried messing around with the jar script and made it like this but it didn’t fix my error:
tasks.withType<Jar>() {
manifest {
attributes["Main-Class"] = "MainKt"
}
from(sourceSets.main.get().output)
from(configurations.runtime.get().map { if (it.isDirectory) { it } else { zipTree((it)) }})
}
My file structure looks like this:
I have literally tried everything. Here’s my stacktrace
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 1 more
I have searched the whole internet from the ground up and still couldn’t find answers to my question.
Here’s the full code of build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.5.10"
}
version = "0.0.1-SNAPSHOT"
group = "HIDDEN"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
implementation("com.google.code.gson:gson:2.8.7")
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.0")
}
tasks.test {
useJUnit()
}
tasks.withType<Jar>() {
manifest {
attributes["Main-Class"] = "MainKt"
}
from(sourceSets.main.get().output)
from(configurations.runtime.get().map { if (it.isDirectory) { it } else { zipTree((it)) }})
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
Any help will be highly appreciated.
Thank you.