Unable to Run Kotlin Application in Eclipse

后端 未结 7 1327
轻奢々
轻奢々 2020-12-18 17:50

In order to create my first, simple Kotlin project in Eclipse, I followed the steps in Getting Started with Eclipse Luna tutorial from Kotlin official website, i.e.:

相关标签:
7条回答
  • 2020-12-18 18:24

    Try new Kotlin File instead of Kotlin Class:

    0 讨论(0)
  • 2020-12-18 18:26

    I had the same problem, it solved by deleting the JAVA_HOME environment variable.

    I have set an old JDK folder that I deleted in the JAVA_HOME environment variable.

    0 讨论(0)
  • 2020-12-18 18:27

    Tried with Java 8 (1.8.0_144) and Eclipse Oxygen.1a Release (4.7.1a - build id 20171005-1200) with the following plugin versions:

      Kotlin    0.8.2.v20170314-0957    org.jetbrains.kotlin.feature.feature.group  JetBrains
        kotlin-eclipse-policy   0.8.2.v20170314-0957    org.jetbrains.kotlin.policy.feature.group   JetBrains
        kotlin-weaving-feature  0.8.2.v20170314-0957    org.jetbrains.kotlin.weaving.feature.feature.group  JetBrains
    

    Everything worked as expected, without the need to create a separate workspace and/or use Kotlin File instead of Kotlin Class:

    0 讨论(0)
  • 2020-12-18 18:30

    For me it happened only once. I think this is some glitch from the Kotlin plugin, when you first create a Kotlin file and try run it. Try "new Kotlin class" paste the same content and see if it works. After that you should be able to run both files as it happened to me.

    0 讨论(0)
  • 2020-12-18 18:32

    I got same issues as you. I tried a lot of ways but not work (like uninstall plugin, then install plugin again, delete project and create new project...)

    How to fix: I created a new workspace and setup the helloworld project again. I see that class file generated and I can run it normally.

    Note that, we create new workspace and not project. What I notice is workspace contain .metadata folder that may have lot of information for Eclipse.

    0 讨论(0)
  • 2020-12-18 18:37
    1. Go to Windows->show view->navigator
    2. Edit the .project file, changing just the following section to compile Kotlin file into same location as the Java files.
    <linkedResources>
            <link>
                <!--name>kotlin_bin</name-->
                <type>2</type>
                <locationURI>org.jetbrains.kotlin.core.filesystem:/FindUniqueStrings/bin</locationURI>
            </link>
    </linkedResources>
    

    Keep in mind:

    1. I have commented out the name tag. Otherwise, Kotlin complier creates src folder kotlin_bin and puts your kotlin file in this folder and the kotlin runtime will not find it.
    2. The name of my java project is entitled FindUniqueStrings. Yours will be different.
    3. Double check that your java class files are complied into your project's bin folder by locating these files in the Navigator view.
    0 讨论(0)
提交回复
热议问题