Kotlin And Java In The Same Project Using Eclipse IDE

后端 未结 5 1484
轻奢々
轻奢々 2020-12-30 02:21

I posted a similar question regarding gradle but this question is without gradle or maven.

I can not get Kotlin working properly using Eclipse IDE. This works great

相关标签:
5条回答
  • 2020-12-30 03:01

    I'm working on a project with Spring Boot and Kotlin (some controllers/mappers/classes in Java and others in Kotlin) and after trying a lot of approaches, the only that worked was to use Eclipse 03-2020 and Kotlin Plugin for Eclipse V0.8.19.

    https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/0.8.19/

    • Before everything, close your project and uninstall the previous version of Kotlin Plugin for Eclipse.
    • Go to Help/Install New Software.
    • Copy the link of Eclipse Plugin and continue with the installation (do not forget to check all the options to install).
    • After the installation restart the IDE and try compile again.
    0 讨论(0)
  • 2020-12-30 03:07

    Add Kotlin Nature fixes the issue. Click on your project and Configure Kotlin -> Add Kotlin nature

    0 讨论(0)
  • 2020-12-30 03:07

    As of the current Eclipse version (2019-09):

    You can't add Kotlin to a Java project, but you can add Java to a Kotlin project.

    The procedure to accomplish a mixed Kotlin/Java project was roughly:

    1. Install Kotlin plug-in
    2. Create empty Kotlin project
    3. Move the Java code into the Kotlin project
    4. Delete the original project
    5. Fix project references
    0 讨论(0)
  • 2020-12-30 03:10

    Add Kotlin Nature fixes the issue. Click on your project and Configure Kotlin -> Add Kotlin nature

    This partially fixes the issue, though eclipse plugin is still buggy and auto import function still doesn't work for me.

    If you're having any issue, make sure you have kotlin_bin folder added in your project. Also make sure that ALL kotlin files have the correct package name sometimes when you rename packages or move files around kotlin classes may not get updated.

    0 讨论(0)
  • 2020-12-30 03:17

    Got similar issue solved by adding a new Kotlin file to a Kotlin/Java mixed project. Adding the file caused Eclipse 2018-09 (4.9.0) to add kotlin-stdlib.jar and kotlin-reflect.jar to classpath and everything started working.

    0 讨论(0)
提交回复
热议问题