Adding Kotlin build-system to Sublime Text 3

Hello all, this is a small tip for all the Sublime Text lovers out there. Since there are no such plugin, this simple build tool will add a compile and run facility of Kotlin script from inside Sublime Text 3. 

Kotlin is the newest sensation among Android and Java developers. Since Google announced that they are officially adding Kotlin to the Android Studio, developers are flocking in to have a look at this new language. Though there are quite a number of apps out there developed with Kotlin, it is certainly a great news for all app-devs especially to those who have been waiting for something as-good as Apple’s Swift. Kotlin is lightweight, modern and way-easier than Java. The best thing about this language is that it is completely convertible and interchangeable with Java and run under JVM. Kotlin is developed by JetBrains, a company famous for making many successful IDEs.

Currently Kotlin can be used with IntelliJ IDEA and Eclipse. These IDEs have full support for Kotlin, and of coarse, they are huge in size. The reason to use Sublime Text is not only because we have limited disk-space and RAM to run bulky IDEs, its because we are really in love with this tiny editor. So let’s create a build system for Kotlin.

  1. Download the latest Kotlin compiler.  If you don’t already have JDK installed, install it now.
  2.  extract the ziped compiler to somewhere.
  3.  Install the Sublime Text 3 if haven’t already.  Go to Tools > Build-system > New Build System
  4. you will meet a blank file. Delete everything in it and paste these lines.
  5. This code is for windows. For linux change your "path/to/Kotlinc/bin/kotlinc" in line 2. You will also need to change \\\\ to / in line 2 and 12.

  6. Name the file kotlin.sublime-build and save it to ~sublime folder/Data/Packages/User/. In linux it should be in "/home/user/.config/sublime-text-3/Packages/User"
  7. Restart Sublime Text. Create a new files with these lines and save it with a .kt extension (ie. hello.kt)
package hello 

fun main(args: Array<String>) { 
   println("Hello World!") 

Now use Ctrl+Shift+B to first compile and then run the code.

Don’t forget to install the Kotlin language package. It seems your compiler is a bit slow, why don’t you switch to Gradle continuous build system.


  1. Hello

    I’m new to programming and all. I followed this step by step but it didn’t work. I think I haven’t done something with the compiler.

    After extracting it to somewhere, what exactly am I supposed to do with it?
    (Tried checking their official site, after reading it, and checking out other forums, I still don’t have a clear picture as to what to do with the compiler).

    Sorry for my noobness but I would appreciate the help

  2. Most Linux users can probably figure out what to do, but here it is step-by-step.
    $ sudo apt update
    $ sudo apt install default-jdk
    $ curl -s | bash
    $ sdk install kotlin
    $ source "/home//.sdkman/bin/"

    Follow Sunbeam’s instructions for the build file, but use this instead
    "cmd": ["/home//.sdkman/candidates/kotlin/current/bin/kotlinc", "$file", "-include-runtime", "-d", "$file_path/$file_base_name.jar"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "working_dir": "$file_path",
    "selector": "source.Kotlin",
    "variants": [
    "name": "Run",
    "cmd": ["java", "-jar", "$file_path/$file_base_name.jar"]

  3. You didn’t mention in the article that you are using Windows. Where is the Linux version of the configuration file?