Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Working Locally

Note

This is a guide to how to work on the programming tasks using either the Linux PCs in the SoCS labs or your own PC. We assume that you have already cloned your GitHub respository to one of these environments.

These instructions do not apply if you are working in a Codespace.

On SoCS Lab Machines

The JDK and Kotlin command line compiler have already been installed for you on the Linux machines in the SoCS labs, so there is nothing that you need to install1.

To access the Kotlin compiler on lab machines, you must first enter the following command in a terminal window:

module load kotlinc

Check that this has worked with

kotlinc -version

You should see a line printed, giving version details for the Kotlin compiler and the underlying Java Virtual Machine.

Tip

If you don’t want to be continually entering this command in every terminal window you work from, you can instead edit ~/.bashrc and add the module load command to the end of this file.

After saving your changes to ~/.bashrc, start a new terminal window and you should find that the Kotlin compiler is now available. It will be available to you every time you log in from this point on.

We leave the choice of code editing environment up to you. The lab machines provide a reasonably up-to-date version of VS Code, which you can access via the Applications menu, and more traditional choices such as Vim or Emacs are also available.

On Your Own PC

As a minumum, you need the Java Development Kit (JDK) and Kotlin’s command line compiler installed. JDK 21 is ideal, but other versions (newer or older) should work OK too.

JDK Installation

If you are running Linux, the easiest way of getting the JDK is probably via your Linux distribution’s own package manager. Alternatively, you can use a third-party package manager such as SDKMAN. With this set up, you can install any one of a number of JDK distributions. We recommend installing the Eclipse Temurin JDK, like so:

sdk install java 21.0.8-tem

On macOS, you can use SDKMAN as outlined above, or you can use the popular Homebrew package manager instead. For example, with Homebrew installed, you can install the JDK like so:

brew install openjdk

On Windows, you can use SDKMAN as above, although installing it isn’t as straightforward. You may find it easier to just install a JDK manually, without using a package manager. You can download a suitable version from adoptium.net.

Note

If installing manually on Linux, macOS or Windows, you will need to modify the PATH environment variable to include the directory containing the java and javac executables.

After installing, check the installation by entering this command:

java -version

You should see a few lines displayed, giving the version and name of the installed JDK.

Kotlin Compiler

If you have SDKMAN on your system, the compiler can be installed with

sdk install kotlin

On a macOS system running Homebrew, it can be installed with

brew install kotlin

To install manually, without using a package manager, download the compiler from GitHub. Unzip the Zip archive in a suitable location on your system, then modify your PATH variable to include the bin subdirectory containing the kotlinc executable.

After installing the compiler, check that you can access it with

kotlinc -version

You should see a line printed, giving version details for the Kotlin compiler and the underlying Java Virtual Machine.

IntelliJ IDEA

IntelliJ IDEA (hereafter referred to simply as IntelliJ) is a powerful IDE from JetBrains, the creators of Kotlin. It is suitable for developing software in Kotlin, Java and other languages.

You will not be able to use IntelliJ on SoCS lab machines, but you do have the option of using it on your own PC.

You can use the Community Edition without a license. You can also use the full professional edition (‘IntelliJ IDEA Ultimate’) for free if you request a student license.2

Please read our advice on using IntelliJ if you plan on using it for the tasks.

Warning

IntelliJ is a demanding application that requires a reasonably up-to-date computer to run well.

8 GB of RAM should be consider the absolute minimum spec, though more RAM is strongly recommended. You will also need plenty of free disk space.


  1. If you are using VS Code as an editor, you may wish to install the Kotlin Language extension. See the info on working in Codespaces for details of how to do this.

  2. This student license applies to many other JetBrains products besides IntelliJ, and it must be renewed annually during your studies.