If you’re following along with the second edition of our Kotlin Programming Guide and you’re using the latest version of IntelliJ IDEA, you’ll notice that some of the steps to create a new project don’t quite match up with the options that IntelliJ will present you. That’s because IntelliJ has had a few updates since we published the book — and in one of them, JetBrains changed some of the templates in the Kotlin project wizards.
But fear not! If you’re working on any of the projects from Chapter 1 through 23 (the bounty-board, NyetHack, TaernylAir, and Interop projects), the steps are very similar to what’s presented in the book. Here’s the gist:
- Follow the steps presented in the book, using the “Kotlin” option in the left column of the New Project wizard. Instead of using the “Application” template, choose “Console Application” which is listed under the “JVM” section.
- Be sure to choose the Gradle Groovy build system, and to set a Project JDK as shown in the book.
- Click Next, then Finish.
- IntelliJ will churn away at making the new project. Unlike what’s shown in the book, the “Console Application” template includes a
Main.ktfile automatically. You will need to delete this file for the rest of the steps in the book to work as expected. To delete this file, locate it in the “Project” pane (it’s in
src/main/kotlin/Main.kt). Right click this file and choose “Delete…”. A “Delete” dialog will appear asking you to confirm that you wish to delete this file. You can leave the options on this dialog at their defaults, and then click “OK.”
- IntelliJ will delete this file, and you’ll be left with a blank Kotlin project — matching the previous “Application” template used by the book. You can now follow the rest of the steps in the book exactly as they’re written.
In Chapter 24 through 26, though, there are different steps to make your project. These chapters guide you through creating a Kotlin Multiplatform project called Doubloons4Gold. The choices presented in the KMP project wizard have also changed, and the steps to create this project are quite a bit from the original printing. Here is a link to updated instructions to create the Doubloons4Gold project. This PDF replaces pages 474 and 475 in the original printing.
Hope that helps! If these steps change in the future, we’ll be back with another update. Let us know if you have any questions while working through our Kotlin book, and happy coding!