The latest instance of the course can be found at: O1: 2024
- CS-A1110
- Supplementary Pages
- Installing IntelliJ
Luet oppimateriaalin englanninkielistä versiota. Mainitsit kuitenkin taustakyselyssä osaavasi suomea. Siksi suosittelemme, että käytät suomenkielistä versiota, joka on testatumpi ja hieman laajempi ja muutenkin mukava.
Suomenkielinen materiaali kyllä esittelee englanninkielisetkin termit.
Kieli vaihtuu A+:n sivujen yläreunan painikkeesta. Tai tästä: Vaihda suomeksi.
Installing IntelliJ
As explained in Chapter 1.2, O1’s official programming environment is IntelliJ IDEA (just IntelliJ for short) and its plugin A+ Courses. These tools are installed on Aalto IT’s Linux workstations.
If you want to use IntelliJ on your personal computer, you’ll need to install it as described on this page. IntelliJ is available for Windows, macOS, and Linux, at no cost. The newer your operating system, the less likely it is that you’ll run into trouble while installing.
(Aalto IT also provides a virtual Linux desktop that you can access over the network from your own computer. The virtual desktop, which is also briefly introduced in Chapter 1.2, probably won’t give you the smoothest IntelliJ experience, though.)
To use IntelliJ IDEA (just IntelliJ for short) for programming on your on your personal computer, you’ll need to install it as described on this page. It is available for Windows, macOS, and Linux, at no cost. The newer your operating system, the less likely it is that you’ll run into trouble while installing.
These links take you to the appropriate installation instructions below on this page:
Version numbers matter!
Any tools that you use in O1 should be compatible with version 2.13.6 of the Scala programming language.
We use the IntelliJ version called Community Edition 2021.3. The recommended version of IntelliJ’s A+ Courses plugin is 3.4.
You’ll also need a Java toolkit (JDK); the recommended version is 11.
The instructions on this page will help you find the appropriate versions.
Windows
Step 1/5: Install IntelliJ
Download IntelliJ IDEA Community, version 2021.3. Make sure to pick the Community edition, not the commercial Ultimate edition. Choose the Windows (exe) installer.
With the installer downloaded, double-click to run it.
Unless you have a particular reason to do otherwise, the default responses to the installer’s questions will do.
If you’re going to continue to the next step right away, you may as well check the Run IntelliJ box in the last screen.
Step 2/5: Launch IntelliJ
If you didn’t already start IntelliJ at the end of the previous step, do it now. You can
do that via the Start menu, for example (or via the file idea64.exe
that is
under the folder where you installed IntelliJ, in the bin
subfolder).
On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.
On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.
Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.
At the next prompt, under Project name, write a suitable name for your
course project (e.g., o1
or o1assignments
). Under Project
location, you can mark which folder you’d like IntelliJ to store your files in;
the suggested default will do, unless you wish to change it.
Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.
Step 3/5: Fetch the JDK toolkit into IntelliJ
While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.
There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.
You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?
- If it happens that yes, there is, pick that option.
- If not, choose Add SDK → Download JDK in the drop-down menu. For Version, pick 11, and for Vendor pick any AdoptOpenJDK. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.
Press OK to close the Project Structure window.
Step 4/5: The A+ Courses plugin
A+ Courses plugin
A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.
Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)
Here’s how to install the A+ Courses plugin:
- In IntelliJ, select File → Settings → Plugins.
- In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
- IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
- IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
- Press Restart IDE to finish up the installation.
- If that button fails to show up, close IntelliJ yourself and relaunch it.
- When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.
Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:
- Select A+ → Turn Project Into A+ Course Project.
- A small dialog window pops up for selecting the course you are taking. Select O1 Fall 2021 and press OK.
- A language menu appears, pick English or Finnish.
IntelliJ also tells you that it’s going to adjust some settings to
suit the course. Press OK to approve.
- Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
- IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
- There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.
Step 5/5: Configure A+ access for assignment submissions
Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):
- Open up your profile page in A+.
- There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
- In the IntelliJ menu, select A+ → Set A+ Token.
- Paste the access token at the prompt and press OK.
macOS
Step 1/5: Install IntelliJ
Download IntelliJ IDEA Community, version 2021.3. Make sure to pick the Community edition, not the commercial Ultimate edition.
Install the program simply by extracting the files from the downloaded package: Click
the file to open it and drag the IntelliJ_IDEA
folder from the package into your
Applications
folder.
Step 2/5: Launch IntelliJ
Launch IntelliJ from the file Idea
.
On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.
On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.
Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.
At the next prompt, under Project name, write a suitable name for your
course project (e.g., o1
or o1assignments
). Under Project
location, you can mark which folder you’d like IntelliJ to store your files in;
the suggested default will do, unless you wish to change it.
Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.
Step 3/5: Fetch the JDK toolkit into IntelliJ
While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.
There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.
You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?
- If it happens that yes, there is, pick that option.
- If not, choose Add SDK → Download JDK in the drop-down menu. For Version, pick 11, and for Vendor pick any AdoptOpenJDK. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.
Press OK to close the Project Structure window.
Step 4/5: The A+ Courses plugin
A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.
Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)
Here’s how to install the A+ Courses plugin:
- In IntelliJ, select IntelliJ IDEA → Preferences → Plugins.
- In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
- IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
- IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
- Press Restart IDE to finish up the installation.
- If that button fails to show up, close IntelliJ yourself and relaunch it.
- When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.
Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:
- Select A+ → Turn Project Into A+ Course Project.
- A small dialog window pops up for selecting the course you are taking. Select O1 Fall 2021 and press OK.
- A language menu appears, pick English or Finnish.
IntelliJ also tells you that it’s going to adjust some settings to
suit the course. Press OK to approve.
- Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
- IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
- There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.
Finally, you can make it easier to launch IntelliJ later by attaching it to the macOS Dock. Right-click the IntelliJ icon in the Dock and select Options → Keep in Dock. Now you’ll be able to find IntelliJ in the Dock.
Step 5/5: Configure A+ access for assignment submissions
Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):
- Open up your profile page in A+.
- There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
- In the IntelliJ menu, select A+ → Set A+ Token.
- Paste the access token at the prompt and press OK.
Linux (Ubuntu)
Step 1/5: Install IntelliJ
Download IntelliJ IDEA Community, version 2021.3. Make sure to pick the Community edition, not the commercial Ultimate edition.
Install the program simply by extracting the files from the downloaded package: Click the file to open it. Extracts its contents in a folder of your choosing.
Step 2/5: Launch IntelliJ
Launch IntelliJ from the file idea.sh
:
- In the Linux Terminal, go to the folder where you extrated the files.
- Enter ./bin/idea.sh to start the program.
On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.
On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.
Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.
At the next prompt, under Project name, write a suitable name for your
course project (e.g., o1
or o1assignments
). Under Project
location, you can mark which folder you’d like IntelliJ to store your files in;
the suggested default will do, unless you wish to change it.
Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.
Step 3/5: Fetch the JDK toolkit into IntelliJ
While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.
There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.
You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?
- If it happens that yes, there is, pick that option.
- If not, choose Add SDK → Download JDK in the drop-down menu. For Version, pick 11, and for Vendor pick any AdoptOpenJDK. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.
Press OK to close the Project Structure window.
Step 4/5: The A+ Courses plugin
A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.
Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)
Here’s how to install the A+ Courses plugin:
- In IntelliJ, select File → Settings → Plugins.
- In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
- IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
- IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
- Press Restart IDE to finish up the installation.
- If that button fails to show up, close IntelliJ yourself and relaunch it.
- When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.
Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:
- Select A+ → Turn Project Into A+ Course Project.
- A small dialog window pops up for selecting the course you are taking. Select O1 Fall 2021 and press OK.
- A language menu appears, pick English or Finnish.
IntelliJ also tells you that it’s going to adjust some settings to
suit the course. Press OK to approve.
- Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
- IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
- There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.
Step 5/5: Configure A+ access for assignment submissions
Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):
- Open up your profile page in A+.
- There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
- In the IntelliJ menu, select A+ → Set A+ Token.
- Paste the access token at the prompt and press OK.
Additional Materials for Special Cases
Why do I keep needing to enter the A+ access token again (on Aalto’s Linuxes)?
IntelliJ stores your A+ access token. However, this storage fails in certain circumstances, causing IntelliJ to prompt you for the token once every session, which is a bit inconvenient.
If this happens to you on Aalto’s Linuxes, the probable cause is that you’ve changed your Aalto password. IntelliJ uses Linux’s built-in password store, but that storage fails after a password change.
You’ll find three alternative solutions below. After you apply one of them, you’ll still need to enter the A+ token once more, but it should then remain in storage even if you close IntelliJ or log off.
Solution 1: Change the storage’s password
If you still remember your first Aalto password, you can change the password storage’s main password to correspond to your current Aalto password:
- Open the applications menu and find Passwords and Keys.
- Right-click Login and select Change password.
- Enter your old password and press Continue.
- Enter your current Aalto password (twice) and finish with Continue.
Solution 2: Re-initialize the password storage
If you don’t remember your earlier password, you can create
a new login.keyring
file to replace the old password storage.
In Linux’s Terminal, enter these commands to remove the old file:
- cd ~/.local/share/keyrings/
- cp login.keyring login.keyring.BACKUP
- rm login.keyring
Create a new login.keyring
with your current Aalto password:
- In the applications menu, find Passwords and Keys.
- Select File → New... → Password Keyring and press Continue.
- Enter
login
as the file name. When prompted enter your Aalto password and press Continue.
Solution 3: Store the access token differently
You can make IntelliJ store the token in a different way:
- In IntelliJ, select File –> Settings –> Appearance & Behaviour –> System Settings –> Passwords.
- Under Save passwords, pick In KeePass.
- The default location that IntelliJ suggests should be OK. Press Apply and OK.
What if A+ Courses does not work on my computer or I don’t want to use it?
If you don’t use the A+ Courses plugin, you’ll have to go to more trouble fetching, configuring, and submitting O1’s programming assignments and when using IntelliJ’s REPL, which we’ll be using a lot.
We strongly recommend that you use the plugin. However, if you don’t, the instructions below may be of use.
Initializing the O1 project (without the A+ Courses plugin)
Install IntelliJ as instructed above, but when you launch it for the first time, do a few things differently.
Before creating a new project, in the Welcome to IntelliJ IDEA screen, install the Scala plugin:
- Select Configure –> Plugins.
- If Scala does not immediately show up in the list, enter Scala in the search field. Select the Scala plugin and press Install.
- After installing Scala, IntelliJ needs to restart. Press Restart IDE.
Now select New Project. In the list of project types on
the left, pick Scala. In the list that shows up,
select IDEA. In the following screen, under
Project name type a descriptive name for the project
(e.g., o1
). IntelliJ suggests a folder for the project,
which you may edit if you wish.
Next, you’ll have to install appropriate toolkits (a JDK and a Scala SDK):
- Click the JDK drop-down menu and select Download JDK.
- Under Vendor, pick AdoptOpen JDK (HotSpot). Under Version, pick 11.0.11. You’re free to select a download folder. Then press Download and IntelliJ will fetch the selected JDK.
- Next to the Scala SDK drop-down menu, press Create. Then choose Download and pick version 2.13.6. Press OK.
- Press Finish. Your new project opens in IntelliJ. IntelliJ shows a tip-of-the-day, which you can Close.
- Select File → Project Structure... → Libraries. Press the little plus icon + and select scala-sdk-2.13.6.
- IntelliJ informs you that the selected toolkit will be associated with your project. Confirm with OK, then Yes.
Importing course settings to IntelliJ (without the A+ Courses plugin)
First, import O1’s project-specific settings:
- Exit IntelliJ.
- Download the settings file o1_2021_project_settings.zip and save it in a folder of your choosing.
- Open the
zip
file. Extract the.idea
folder into your project folder so that its contents (partially) replace the contents of the project folder’s.idea
subfolder.- That is, don’t nest the two
.idea
folders and don’t start by deleting the old.idea
folder.) - It is possible that your operating system
is configured not to show hidden files
and folders (whose names begin with
a period like
.idea
) in folder listings. In that case, you’ll want to adjust that setting.
- That is, don’t nest the two
- When extracting the files, you’ll be asked if you want to replace the identically named files already there. Do replace them.
- Restart IntelliJ.
Second, you should import O1’s generic IntelliJ settings:
- Download the settings file and save it in a folder of
your choosing. The file that you need depends on your
operating system:
- Windows or Linux: o1_2021_ij_settings.zip
- MacOS: o1_2021_ij_mac_settings.zip
- In IntelliJ, select File → Manage IDE settings → Import settings.
- When prompted for a file, choose the settings file that you just downloaded.
- Make sure that all the boxes are checked and press OK.
- Confirm another Restart.
Fetching O1’s modules into IntelliJ (without the A+ Courses plugin)
At the top of each ebook chapter, you’ll find links to the related course modules (i.e., example programs and base code for programming assignments). With A+ Courses, you don’t need those links, because IntelliJ will download and install the modules in a snap, but you can do the same manually.
Follow the module link and download the corresponding zip
file onto your
computer. Extract its contents in your project folder. Once you do that,
the files will show up in IntelliJ’s Project view on the left,
but you still need to mark them as submodules of the overall O1 project.
Open the new module’s folder in IntelliJ. Right-click the file with an
.iml
name suffix. Select Import '[Module name]' Module.
Submitting assignments (without the A+ Courses plugin)
The A+ Courses submits your work directly from IntelliJ. As an alternative, you can use the web forms that you find in the ebook chapters.
Many web browsers let you drag and drop the file straight from IntelliJ into the field below. If it doesn’t work for you, click in the web form and locate the file within your project folder.
Launching the Scala REPL in a specific module (without the A+ Courses plugin)
Without the A+ Courses plugin, IntelliJ does not know how to set launch the REPL so that the code you write is easily accessible from within the REPL.
If you don’t use the plugin, you’ll need to create a new run configuration when you start working with a new module:
- Select Run → Edit Configurations.
- Click the little plus icon + at the top left.
- In the list, select Scala REPL.
- In the Name field at the top, enter a descriptive name such as “REPL [Module Name Here]”.
- Under Use classpath and SDK of module:, select the appropriate module.
- Press Apply and OK.
- You can now launch that run configuration to start the REPL. One way to do that is to find it the drop-down menu in IntelliJ’s top right-hand corner and press the play button .
Apart from taking care of run configurations for the REPL, the A+ Courses
plugin saves your fingers by automatically import
ing certain relevant
packages of Scala code (such as package o1
) after you’ve started the
REPL. Without the plugin, you’ll need to every package that you need
whenever you use the REPL. For example:
import o1._import o1._ import o1.goodstuff._import o1.goodstuff._
Chapter 1.6 says more about packages and Scala’s import
command.
Feedback
Credits
Thousands of students have given feedback that has contributed to this ebook’s design. Thank you!
The ebook’s chapters, programming assignments, and weekly bulletins have been written in Finnish and translated into English by Juha Sorva.
The appendices (glossary, Scala reference, FAQ, etc.) are by Juha Sorva unless otherwise specified on the page.
The automatic assessment of the assignments has been developed by: (in alphabetical order) Riku Autio, Nikolas Drosdek, Joonatan Honkamaa, Jaakko Kantojärvi, Niklas Kröger, Teemu Lehtinen, Strasdosky Otewa, Timi Seppälä, Teemu Sirkiä, and Aleksi Vartiainen.
The illustrations at the top of each chapter, and the similar drawings elsewhere in the ebook, are the work of Christina Lassheikki.
The animations that detail the execution Scala programs have been designed by Juha Sorva and Teemu Sirkiä. Teemu Sirkiä and Riku Autio did the technical implementation, relying on Teemu’s Jsvee and Kelmu toolkits.
The other diagrams and interactive presentations in the ebook are by Juha Sorva.
The O1Library software has been developed by Aleksi Lukkarinen and Juha Sorva. Several of its key components are built upon Aleksi’s SMCL library.
The pedagogy of using O1Library for simple graphical programming (such as Pic
) is
inspired by the textbooks How to Design Programs by Flatt, Felleisen, Findler, and
Krishnamurthi and Picturing Programs by Stephen Bloch.
The course platform A+ was originally created at Aalto’s LeTech research group as a student project. The open-source project is now shepherded by the Computer Science department’s edu-tech team and hosted by the department’s IT services. Markku Riekkinen is the current lead developer; dozens of Aalto students and others have also contributed.
The A+ Courses plugin, which supports A+ and O1 in IntelliJ IDEA, is another open-source project. It was created by Nikolai Denissov, Olli Kiljunen, Nikolas Drosdek, Styliani Tsovou, Jaakko Närhi, and Paweł Stróżański with input from Juha Sorva, Otto Seppälä, Arto Hellas, and others.
For O1’s current teaching staff, please see Chapter 1.1.