I am trying to call Comparator.comparingLong with ...
# announcements
d
I am trying to call Comparator.comparingLong with kotlin lambda syntax and I get the error: Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8' maven kotlin My IntelliJ Project Structure says to compile for platform JVM 1.8, my Settings in IntelliJ say for the Kotlin Compiler to use target 1.8, and maven has the following in the properties tag:
Copy code
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
I don't understand why I get this error. If anyone has insight or a fix please share!
d
@ephemient That did not work for me 😧
Copy code
<properties>
    <ktor_version>1.3.0</ktor_version>
    <kotlin.code.style>official</kotlin.code.style>
    <kotlin_version>1.3.61</kotlin_version>
    <logback_version>1.2.1</logback_version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>

    <main.class>io.ktor.server.netty.EngineMain</main.class>
</properties>
e
hmm. if
<args><arg>-jvmTarget=1.8</arg></args>
works then maybe something is wrong with the maven plugin, if it doesn't work then maybe something is wrong with kotlinc :-/
sorry, I only use Gradle (and it seems like that's what JetBrains mainly uses too)...
d
Building it was a success, so I invalidated caches & restarted and now there's no error. what can I say ._.
e
Maven always did involve a lot of building-from-scratch when I last used it (many years ago), for whatever reasons. not that Gradle is perfect either, but the problems are different 😄
m
Did you set up the kotlin plugin correctly?
Copy code
<plugin>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-maven-plugin</artifactId>
    <version>${kotlin.version}</version>
    <configuration>
        <compilerPlugins>
            <plugin>spring</plugin>
            <plugin>jpa</plugin>
        </compilerPlugins>
        <jvmTarget>${maven.compiler.target}</jvmTarget>
    </configuration>
</plugin>