Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

Kotlin class in other package not resolved

$
0
0

I started with Kotlin and want to exclude files in other packages in Visual Studio Code. Unfortunately it does not work

Person.kt

package com.example

public class Person(
    val _firstName: String,
    val _lastName: String,
    val _age: Int
)

main.kt

import com.example.Person

fun main(args: Array<String>) {
    val person = Person("Peter","Pan",12)
    println(person)
}

When I hover over in the main function Visual Studio Code show me the Person class, thus it seems that it is recogniced but as far as I run the code I get the following error

[Running] cd "c:\Users\Matthias\Desktop\Kotlin\"&& kotlinc Main.kt -include-runtime -d Main.jar && java -jar Main.jar
Main.kt:1:12: error: unresolved reference: example
import com.example.Person
           ^
Main.kt:4:18: error: unresolved reference: Person
    val person = Person("Peter","Pan",12)
                 ^

I played around with other package names like "domain" but then the whole class is not found. I put them in folder but the error stays the same.


Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>