# Errors running kotlin class from comd-line

**URL:** <https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800>\
**Category:** Uncategorized\
**Created:** [October 20, 2025, 12:08pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800 "2025-10-20T12:08:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [October 20, 2025, 12:08pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/1 "2025-10-20T12:08:18Z")

</div>

hello everyone,

I’m trying to run a kotlin class from CLI([Kotlin command-line compiler | Kotlin Documentation](https://kotlinlang.org/docs/command-line.html#create-and-run-an-application)), but I get some errors:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/f/f438507ef51a0277699e86512589ac5b9ca5d72f.png)

Can anyone help me to find out the problem??

Thanks to all,

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [October 22, 2025, 9:47am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/2 "2025-10-22T09:47:49Z")

</div>

Can you include the code you’re trying to compile?

Though tbh, this looks like a bug with the compiler. I’ve just briefly skimmed the docs, but using the `-include-runtime` flag should include Kotlin runtime library (which I assume is the same as the standard library?) so you should be able to use code from the standard library like `println`.

How did you install the compiler? Maybe it’s missing the runtime library, or something?

---

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [October 22, 2025, 3:56pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/3 "2025-10-22T15:56:56Z")

</div>

The code of my app is really simple @Skater901:

```auto
fun main() {
    println("Hello, World!")
}

```

I download compiler from GitHub, I didn´t install it (I don’t know how to install it) Is it needed to install it??

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [October 23, 2025, 1:15am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/4 "2025-10-23T01:15:12Z")

</div>

Nope, looks like you did the steps correctly: [https://kotlinlang.org/docs/command-line.html#manual-install](https://kotlinlang.org/docs/command-line.html#manual-install)

Tbh I’ve never used the command line compiler. Is there a reason you’re using it instead of IntelliJ? I don’t think I can help, unfortunately. ☹

---

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [October 23, 2025, 3:37pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/5 "2025-10-23T15:37:26Z")

</div>

Thanks for you reply @Skater901.

There’s no any special reason for using command line compiler. Simply, in my old PC I don´t have enough RAM to install IntelliJ………… the message error is very confusing for me, definitively, I don’t understand the problem 🤔

---

<div class="post-metadata">

**Author:** ![gidds](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/gidds/32/10865_2.png) [@gidds](https://discuss.kotlinlang.org/u/gidds)\
**Post date:** [October 23, 2025, 7:11pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/6 "2025-10-23T19:11:42Z")

</div>

I don’t understand either, but my rough guess is that it can’t find the Kotlin standard library (which is where `println()` et al are defined). So I’d poke around and try to confirm that it came with the compiler and is where the compiler is likely to find it.

(The `-include-runtime` flag is related but slightly different, as that will include the standard library in the output jar. But even if it’s not doing that, the compiler will need access to it while compiling, in order to identify the correct classes and methods.)

---

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [July 14, 2026, 3:38pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/7 "2026-07-14T15:38:53Z")

</div>

Hello again,

I’ve created [build.gradle.kts file](https://codingtechroom.com/question/resolve-kotlin-unresolved-reference-println-gradle-cli) but I’m still with the same error 🙂‍↕️

 ![image](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/5/56a2fde8abf3649c43301a088371da1fcdb8027d.png)

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [July 15, 2026, 10:23am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/8 "2026-07-15T10:23:41Z")

</div>

Are you actually using Gradle?

Gradle requires `gradle/gradle-wrapper.jar`, and also a `gradlew` bash script (or `gradlew.bat` script for Windows). You then compile your code by invoking the `gradlew` script. `./gradlew compileKotlin`.

Also you don’t need to include the Kotlin stdlib as a dependency; the Kotlin plugin automatically adds the stdlib as a dependency.

---

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [July 15, 2026, 11:14am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/9 "2026-07-15T11:14:02Z")

</div>

I don´t know anything about Gradle, I only use Gradle because [docs](https://codingtechroom.com/question/resolve-kotlin-unresolved-reference-println-gradle-cli) recomend it: :

> The ‘unresolved reference: println’ error in Kotlin typically arises when the Kotlin standard library is not properly included in your project. **This issue can occur while using Gradle** from the CLI if the configuration is incorrect or if the environment is not set up properly."

I get stack but i don´t know if I need to use Gradle. I don’t know about Gradle so I’d prefer not to use Gradle if there are another ways but I don’t know if there are more ways to find out the problem

if i don’t use Gradle, what more can I do ??

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [July 15, 2026, 11:28am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/10 "2026-07-15T11:28:36Z")

</div>

Oh, yeah I would ignore that. That’s talking about an error that can occur when you’re using Gradle. But you weren’t using Gradle, so that specific error is irrelevant to you. I would remove all Gradle stuff, just stick to having your code and the CLI compiler.

I’ll download the compiler myself and give it a go, see if I can get it working.

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [July 15, 2026, 11:34am UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/11 "2026-07-15T11:34:46Z")

</div>

Ok, I was able to make it work with the latest compiler. I would say maybe there’s a bug in the specific compiler you downloaded. Download the latest version of the compiler (2.4.10) and try again.

BTW, you might not want to compile to a `.jar` file; if you omit the `-d s1.jar`, it’ll just compile it to a Java class file that you can run. You want to compile to a `.jar` file once you start having multiple files in your project.

---

<div class="post-metadata">

**Author:** ![ppinedo](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@ppinedo](https://discuss.kotlinlang.org/u/ppinedo)\
**Post date:** [July 15, 2026, 12:01pm UTC](https://discuss.kotlinlang.org/t/errors-running-kotlin-class-from-comd-line/30800/12 "2026-07-15T12:01:39Z")

</div>

ok, many thanks @Skater901…thanksSkater901…thanks a lot for your help 🫠

 ![image](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/5/54b475d4d7fd2bb55a7a643c6ae913dfe4ad5a31.png)
