License
Kotlin compiler, library, IDE plugin and tools such as Ant and Maven integrations are available under the Apache 2 Open Source License.
Standalone compiler
A standalone compiler, can be downloaded from here.
Setting up IntelliJ IDEA
For Kotlin M3 and higher, you need to install IntelliJ IDEA 12.
Once you've installed that, you'll need the Kotlin IDEA Plugin.
Milestone versions
A stable milestone version of Kotlin can be obtained from JetBrains' Plugin Repository.
In IDEA navigate to: Settings -> Plugins -> Browse Repositories
Select the Kotlin plugin and then Download and Install.
Using the Kotlin nightly builds
In IDEA navigate to: Preferences -> Plugins -> Browse Repositories. Enter
Then you should be able to select the Kotlin plugin and Download and Install. The repository above contains nightly builds published automatically.
Download the Kotlin plugin manually
Alternatively, you can download the nightly builds of the IDEA Plugin from our build server, look under "Artifacts".
Then navigate to Preferences -> Plugins -> Install plugin from disk...
Creating a project
- Now in IDEA you can select File -> New Project.
- Create a new project as usual with a src directory.
- Right click on src and select New -> Kotlin file
- Enter some name, say 'Foo'
- The IDE will prompt you at the top right of your editor to select the Kotlin Runtime
- You'll need to point the IDE to some download of the Kotlin runtime (see below)
- Enter some code like this
fun main(args: Array<String>): Unit { println("Hello world!") }- Now thats done you should be able to right click on the Foo class and select Run
- Enjoy!
Working with the Kotlin project at github
Please note that the root project at github is a Java based project for creating the compiler and IDEA plugin. It should not be opened in IDEA with the Kotlin plugin installed!
However the kotlin libraries project is all Kotlin code and used to create the standard library, tests and associated tools. That project opens fine in IDEA with Kotlin plugin installed. You just may have to specify which KotlinRuntime to choose.
Downloading the Kotlin Runtime
The IDEA plugin already includes a Kotlin runtime. If you want to use Kotlin yourself from the command line or Ant you may need this too (unless you use other build tools like the Kotlin Maven Plugin).
Download it from our build server (login as Guest, look under "Artifacts"):
- http://teamcity.jetbrains.com/viewType.html?tab=buildTypeStatusDiv&buildTypeId=bt345&guest=1 - IntelliJ IDEA 11
- http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt389&guest=1 - IntelliJ IDEA 12 EAPs
Common Issues
Sometimes you open a Kotlin file and things go all red. This may mean that the IDEA plugin cannot find your Kotlin Runtime.
- Go to File -> Project Structure...
- Select Libraries tab
- Do you see KotlinRuntime? Is it pointing to a valid kotlin-runtime.jar?
- If not remove it and add a new one
