Bootcamp (Boot Camp Assistant) is essentially Apple's way of welcoming Microsoft into its walled garden in a roundabout way. In other words, it allows you to install Windows on a Mac computer by partitioning the disk and letting you dual-boot a laptop or desktop.
This codelab is part of the Kotlin Bootcamp for Programmers course. You'll get the most value out of this course if you work through the codelabs in sequence. Depending on your knowledge, you may be able to skim some sections. This course is geared towards programmers who know an object-oriented language, and want to learn Kotlin.
You should be familiar with:
Kotlin is a new, modern programming language created by programmers, for programmers. It's focused on clarity, conciseness, and code safety.
Kotlin has been around since 2011, and was released as open source in 2012. It reached version 1.0 in 2016, and since 2017 Kotlin has been an officially supported language for building Android apps. It's included with the IntelliJ IDEA as well as Android Studio 3.0 and later.
To see which version of the JDK you have installed, if any, type javac -version
in a terminal window.
You can see what the latest version of the JDK is on the Java SE Downloads page. If you have the latest version, skip ahead to Install IntelliJ IDEA.
Note: We recommend that you install only the latest JDK and JRE.
JRE or JDK?
The JRE (Java Runtime Environment) is needed for running Java and Kotlin programs. The JDK (Java Development Kit), on the other hand, includes the JRE, plus the development tools that you need for writing and running Java programs. You need the JDK for writing Kotlin programs.
You can download the JDK for free here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
From either the Downloads window of the browser, or from the file browser, double-click the .dmg
file to launch the install file.
.pkg
file..dmg
file to save space.jdk-14.0.1_windows-x64_bin.exe
), which installs both the JDK and the JRE. By default, the JDK is installed in the C:Program FilesJavajdk-14.0.1
directory, but it depends on the latest version.edit environment
in Find a setting.C:Program FilesJavajdk-14.0.1bin
, after any existing items.Note: This was tested for JDK 14 installed on Windows 10. Other versions of the JDK may use different directories, and the steps may be different for other versions of Windows.
Windows users: If you receive an error from either command, confirm you've added the correct path for the JRE.
ideaIC.exe
file that you downloaded.Mac:
ideaIC.dmg
file that you downloaded.Linux:
Install-Linux-tar.txt
in the downloaded .tar.gz
file.For more information on how to install and set up IntelliJ IDEA, check out Install IntelliJ IDEA.
Create a Kotlin project so IntelliJ IDEA knows you're working in Kotlin.
Hello Kotlin
.Now you can access the REPL (Read-Eval-Print Loop), Kotlin's interactive shell. Commands that you type into the REPL are interpreted as soon as you press Control+Enter
(Command+Enter
on a Mac).
The first time you run IntelliJ IDEA after installing, it may take a few moments before the Kotlin menu appears under Tools.
Control+Enter
(Command+Enter
on a Mac). You should see Hello World
, as shown below. fun
keyword designates a function, followed by the name. As with other programming languages, the parentheses are for function arguments, if any, and the curly braces frame the code for the function. There is no return type because the function doesn't return anything. Also note that there are no semicolons at the ends of lines.Note: If you're used to putting semicolons at the end of lines, that's OK—Kotlin doesn't mind.
Congratulations! You've written your first Kotlin program.
Control+Enter
(Command+Enter
on a Mac) to run it.The https://play.kotlinlang.org website includes rich tutorials called Kotlin Koans, a web-based interpreter, and a complete set of reference documentation with examples.
Documentation for the IntelliJ IDEA can be found on the JetBrains website.
This section lists possible homework assignments for students who are working through this codelab as part of a course led by an instructor. It's up to the instructor to do the following:
Instructors can use these suggestions as little or as much as they want, and should feel free to assign any other homework they feel is appropriate.
If you're working through this codelab on your own, feel free to use these homework assignments to test your knowledge.
Which of the following is NOT a benefit of using the Kotlin language?
▢ Kotlin distinguishes between nullable and non-nullable data types.
▢ Kotlin is a supported language for building Android apps.
▢ Kotlin is designed so you can write less code with fewer bugs.
▢ Your code compiles faster in Kotlin.
▢ Create a Kotlin project in IntelliJ IDEA, then select Run > Kotlin REPL.
▢ Open IntelliJ IDEA, then select File > Kotlin REPL.
▢ Create a Kotlin project in IntelliJ IDEA, then select Tools > Kotlin > Kotlin REPL.
▢ Kotlin code will run faster than Java code.