How to configure Kotlin target JVM

Hello community, probably silly question incoming:

I’ve set up a project using Kotlin. By default the Kotlin compiler is configured to target JVM 1.6, while the rest of the configuration targets the JVM 1.8. The latter one is desired. This discrepancy causes some problems, e.g. when using assertThrows<Exception>. The error message I get is: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper ‘-jvm-target’ option

Setting the proper target JVM in the project settings is possible, but doesn’t seem to be a viable option. I get warned about these settings coming from the Gradle scripts and being overwritten on the next reimport. I suppose I have to specify the desired JVM target somewhere in the Gradle build script, but at this point I’m honestly lost due to insufficient experience with Gradle.

Could someone provide me a hint how to permanently set the Kotlin target JVM? Thanks a lot!

I have not tried but the setting you need to change is probably this, in File -> Settings dialog:

Another option is to set jvmTarget option in the build.gradle script.

Mentioned here:

As stated in the link, but copied here as a reference, this should do it: (added to the build.gradle file)

compileKotlin {
    kotlinOptions {


thanks a lot for your answers. I added Klaus’ code to my build.gradle, and it seems to work. The project settings/modules do not display this change and still show target JVM 1.6, but as long as it works, I can live with it. :wink: Thanks again!