10

I made a project using kotlin:

Group id-> com.programming.kotlin

Artifact id->chapter01

Module name->chapter01

package->com.programming.kotlin.chapter01

I made a kotlin class called Program.kt

The problem is: when i try to make a new class(called Program2.kt) inside package and when i try to run it ,i got this error:

class com.programming.kotlin.chapter01.Program2kt not found in module 'chapter01_main'

My question is: how to allow any new class other than Main class to run inside intellij ?

6
  • Did you include package com.programming.kotlin.chapter01 into Program2.kt?
    – hotkey
    Jul 5, 2017 at 22:54
  • yes,it's included Jul 5, 2017 at 23:30
  • 1
    The is obviously something wrong with your classpath. Please add some more information: Gradle-script, how you run the application, how you build the application.
    – guenhter
    Jul 6, 2017 at 5:22
  • 1
    hey author did you solved that issue? Jan 26, 2018 at 15:04
  • 1
    i'd had the same problem, right-click on the .kt file and then click on "Run", hope this helps.
    – Naveen
    Jan 15, 2020 at 10:54

1 Answer 1

0

Your class name should be com.programming.kotlin.chapter01.Program2. If you go to InteliJ and right click on the class, you can click Copy Reference, which will copy the class reference (package and class name).

The Kt (with a capital K) is only added to functions without an enclosing class or object.

1
  • whey should by the class name com.programming.kotlin.chapter01.Program2 ?
    – SL5net
    Feb 23, 2021 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.