Im trying to compile and run by my own hands, but I have problem. Im using Intellij IDEA, Kotlin and Gradle. First, I built project (and made .class file), next, in IDE Terminal I typed "gradle build" (this make me .jar file). When Im trying to run this .jar file I got this error:
java -jar appname.jar
Exception in thread "main" java.lang.NoClassDefFoundError: sun/jvm/hotspot/HotSpotAgent
at com.neel.helloworld.MainKt.main(main.kt:12)
at com.neel.helloworld.MainKt.main(main.kt)
Caused by: java.lang.ClassNotFoundException: sun.jvm.hotspot.HotSpotAgent
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 2 more
Im using AdoptOpenJDK8, PATH - user and system variable with java\bin, JAVA_HOME to home java dir.
My build.gradle.kts: (some "options" might look, but Im just trying everything)
plugins {
kotlin("jvm") version "1.3.71"
}
group = "org.dumper"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(files("${System.getenv("JAVA_HOME")}\\lib\\sa-jdi.jar"))
implementation(files("${System.getenv("JAVA_HOME")}\\lib\\tools.jar"))
compile(kotlin("stdlib-jdk8"))
compile(files("${System.getenv("JAVA_HOME")}\\lib\\sa-jdi.jar"))
compile(files("${System.getenv("JAVA_HOME")}\\lib\\tools.jar"))
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
val jar by tasks.getting(Jar::class) {
manifest {
attributes["Main-Class"] = "com.neel.helloworld.MainKt"
}
}