# Compiling and Running kotlinc from source

**URL:** <https://discuss.kotlinlang.org/t/compiling-and-running-kotlinc-from-source/11489>\
**Category:** Support\
**Created:** [February 7, 2019, 10:25pm UTC](https://discuss.kotlinlang.org/t/compiling-and-running-kotlinc-from-source/11489 "2019-02-07T22:25:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcutler.1](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@bcutler.1](https://discuss.kotlinlang.org/u/bcutler.1)\
**Post date:** [February 7, 2019, 10:25pm UTC](https://discuss.kotlinlang.org/t/compiling-and-running-kotlinc-from-source/11489/1 "2019-02-07T22:25:51Z")

</div>

I am interested in doing some minor experimenting with the Kotlin compiler. I would like to try compiling a very basic kt file using a version of kotlinc that I can edit.

I followed the instructions in the README ([GitHub - JetBrains/kotlin: The Kotlin Programming Language.](https://github.com/JetBrains/kotlin)) and was able to get a local copy to compile. But then I’m stuck. The kotlinc script in compiler/cli/bin requires jar files to be in specific named locations, so it isn’t a convenient way to iterate on minor changes to the compiler.

What’s the best way to compile a local version of the kotlin compiler, and then run it on a basic kt file?

---

<div class="post-metadata">

**Author:** ![udalov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/udalov/32/5679_2.png) [@udalov](https://discuss.kotlinlang.org/u/udalov)\
**Post date:** [February 11, 2019, 2:23pm UTC](https://discuss.kotlinlang.org/t/compiling-and-running-kotlinc-from-source/11489/2 "2019-02-11T14:23:42Z")

</div>

There’s a Gradle task in our project called `dist` which builds compiler and libraries and puts them into `dist/kotlinc/lib`, exactly where wrapper scripts, which are also copied to `dist/kotlinc/bin`, expect them to be. So if you change some code in the project and then run:

```
./gradlew dist

```

(or run the corresponding task from the Gradle tool window in IntelliJ), the project will be incrementally compiled (therefore it won’t take a lot of time), and the updated Kotlin compiler will be placed in the `dist` directory, which you can then invoke with

```
dist/kotlinc/bin/kotlinc source.kt -d output.jar

```

You can also define a shell alias `kotlinc` to point to that executable and simplify the command line further.
