ParallelStreams.kts:41:15: error: calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
IntStream.range(0,10).parallel().forEach{a ->
^
Ok ... I'm not trying to compile for 1.6.
File > Project Structure > Project
has project sdk 1.8
and language level 8
.
File > Project Structure > Modules > Kotlin
has target platform: JVM 1.8
.
File > Project Structure > Facets > Kotlin
has target platform: JVM 1.8
.
File > Settings > Compiler > Kotlin Compiler
has target jvm version 1.8
.
My gradle build file ...
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
group 'foo'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.3.0"
//networking
implementation 'com.mashape.unirest:unirest-java:1.4.9'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
I'm running out of places to check for 1.8
.
And yes, I have tried invalidating the cache and restarting Intellij. It does nothing to resolve this issue.
Go to Intellij Preferences -> Build, Execution, Deployment -> Kotlin Compiler. Update Language version and Api version to the one you wish. This should be the accepted answer.
Kotlin 1.6 was released in November 2021. Kotlin 1.7 was released in June 2022, including the alpha version of the new Kotlin K2 compiler.
Add sourceCompatibility
and targetCompatibility
for Java 1.8:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
group 'foo'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
// Add compatibility
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.3.0"
//networking
implementation 'com.mashape.unirest:unirest-java:1.4.9'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
With .kts
just use this:
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
// I am using latest dsl and gradle
val kotlinVersion = "1.3.30"
val gradleVersion = "5.4+"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With