Published 2013-09-01.
Last modified 2019-11-28.
Time to read: 14 minutes.
This lecture is for programmers who would like to use IntelliJ IDEA with this course and those that follow. It has been updated to IDEA 2019.1.1, and discusses special considerations for macOS, Linux and Windows. The demo at the end of the lecture shows various ways of searching, navigating Scala and Java code, viewing project directories and the inheritance hierarchy, working with favorites, multi-pane and multi-window editing and examining dependencies.
Nov 28, 2019: Today’s release of the Scala plugin has some extra goodies. After you work through this lecture, please read the blog post.
Regardless of whether you installed JetBrains Toolbox or not in the previous lecture entitled JetBrains Toolbox, the steps below are essentially the same for installation on MacOS, Linux and Windows. I will point out the differences.
If you did not install JetBrains Toolbox, download IDEA from https://download.jetbrains.com/idea/. If you are using WSL use the version of IDEA bundled with Java 11. The JVM bundled with the IDE is not the same as the the JVM your program uses. For WSL, I typed:
$ cd /opt $ wget https://download.jetbrains.com/idea/ideaIU-2019.1.3-jbr11.tar.gz $ tar -xvzf ideaIU-2019.1.3-jbr11.tar.gz $ ./idea-IU-191.7479.19/bin/idea.sh &
- When you run IntelliJ IDEA for the first time you initially see:
- Windows users will see a dialog that prompts for the location to install IDEA into. The default installation directory is
%HOMEPATH%\AppData\Local\JetBrains\IntelliJ IDEA 2019.1.1
:
- You now have the choice of various installation options. JBR is the JetBrains Runtime, essentially this is the JDK for IDEA that powers IDEA. Note that this is quite separate from the JDK that your projects use. For this version of IDEA, the JBR is OpenJDK 8u202. You have the option of downloading an x86 version of the JBR along with IDEA. I personally have never needed this and I recommend that most people to keep this option disabled.
My recommendations are:- 64-bit launcher only
- Enable Add "Open Folder as Project"
- Create file associations for all filetypes:
.java
,.groovy
and.kt
- Do not enable Download and install JBR x86 since there is no need for the 32 bit launcher
- No need to enable Add launchers dir to the PATH.
- For Windows, you are asked to indicate the Start Menu folder to use. This does not mean much for Windows 10 - I just accept the default value and click the Install button.
- Now we have the pleasure of watching files copy.
- Eventually the copying ends and installation is complete. Enable Run IntelliJ IDEA so we can configure it.
Stage 1 Configuration
- If this is the first time IntelliJ has been installed on this computer, and there is no pre-existing configuration directory in a recognized directory, Windows users will see the following. If this is what you see, then accept Do not import settings and click OK.
Linux users will see the following:
As you can see, Linux users are offered an extra option: JetBrains Account: UI and editor themes, keymaps and plugins option. This option is only useful to users with a JetBrains account that has settings stored in it. I don’t work that way and prefer to keep that private in local files that I copy between machines. Again, click OK. - Otherwise, if you have run IDEA before you will see the following. Although I have settings to import, I want to show you the new user experience, so I selected the last option: Do not import settings. Click OK to advance to the next step.
- You must agree to the terms in order to continue.
- Its is strictly up to you to decide if you want to share your usage statistics with JetBrains.
Stage 2 Configuration
- You now have the choice of user interface theme. Most people I know prefer the Darcula theme for coding, and the IntelliJ theme for presentations. You can easily switch themes at any time, as you will see shortly. The Linux version of IDEA used to offer an extra UI theme called GTK+; that option is gone now. Make your choice and click on Next: Desktop Entry button. I selected Darcula so the rest of this video and the screen shots in the transcript are shown with the Darcula UI theme.
- If you are running Ubuntu Linux you will be presented with a Create Desktop Entry step.
- This is a good thing, and is enabled by default, so click on the Next: Default plugins button. You can always create a desktop icon later from the Tools / Create Desktop Entry menu item.
- Linux users will see the Launcher Script panel next if they did not install JetBrains Toolbox, discussed in the JetBrains Toolbox lecture. The default is to place the generated script in
/usr/local/bin/idea
, but you can override that, for example, Ubuntu users would likely store a script like that in~/.local/bin/idea
. You can create a launcher script at any time by using the Tools / Create Command-line Launcher menu item. When IDEA is installed via JetBrains Toolbox, command line launcher is managed by the Toolbox app to avoid conflicts. Use the Toolbox app to create a command line launcher, if you have an old launcher at the same location, delete it first.
- This is a good thing, and is enabled by default, so click on the Next: Default plugins button. You can always create a desktop icon later from the Tools / Create Desktop Entry menu item.
- The Default Plugins panel appears next, where you select the plugins you wish to enable. I have not noticed issues with having lots of unnecessary plugins enabled, and you can disable plugins easily at any time, so you could press the Next: Featured plugins button and move on. A more conservative approach would be to disable all of the plugins, and then selectively enable the plugins that are of interest to you.
- The Featured plugins panel appears next, and you should click on the Install button for Scala. Wait for the installation to complete before moving on.
- You could install the
Grazie
plugin and enjoy enhanced spellcheck. Be sure to enable all its features as described here. - Now you can click on the Start using IntelliJ IDEA button.
If you ever want to rerun the IDEA configuration from the beginning, you just need to rename or delete the configuration files as described in the JetBrains IDEA documentation.
License
- IDEA now asks if you are already a paying customer and would like to activate this installation, or if you would like to evaluate the product for free for 30 days. Users can activate multiple installations for their own use for no extra charge.
Paying customers have 3 ways to activate this installation:- Via a JetBrains Account (this is my preferred mechanism). If you select this option, enter your Username or email and Password.
- With an Activation code (works well also).
- License server (I’ve never used it).
- If you select Evaluate for free you will see this dialog. Here you can click on the button entitled Buy IntelliJ IDEA. It is a good idea to enable Send me tips to learn IntelliJ IDEA faster, and if you want to do that you need to provide your email address.
- I clicked on the Evaluate button and IDEA’s Welcome panel will appear.
Modifying Plugins (Supplemental)
- When IDEA finally presents the Welcome panel, you will see an pull-down menu at the bottom of the panel labeled Configure. Click on it.
- If you have a settings file to import, which might be called
settings.jar
, then all of the following settings could be imported. - Click on the Plugins menu item. Alternatively, you could click on Settings and then select the Plugins menu item.
- If you are not using Play Framework 1.0 (and you should not unless you were unable to upgrade an old project!), disable the Playframework support plugin because that only works with Play Framework version 1. Unfortunately, you cannot delete this plugin, you can only disable it.
- If the Play 2.0 Support plugin is installed, delete it because its functionality is now subsumed into the Scala plugin. If you fail to do this then Play features will not work properly.
- Click on the Install JetBrains plugin... button. The Browse JetBrains Plugins panel will open.
- Type
scala
into the search box - Highlight the Scala plugin and right-click, and if that plugin had not already been installed you would see Download and Install and you would select this menu item.
- You could install the official JetBrains Markdown Support plugin if you like now.
- Click on the Close button so the Browse JetBrains Plugins panel closes.
- If you are using Play Framework 2.0, also install the Remote Call plugin:
- Click on the Browse Repositories button and wait for the plugins to download.
- Type
remote call
into the search box. - Right-click on the Remote call plugin in the search results and select Download and Install.
- Close the Plugins window by clicking OK.
- Click on the Browse Repositories button and wait for the plugins to download.
- Allow IntelliJ IDEA to restart. Windows users will see the following dialog. Enable both private and public network traffic so various plugins can work:
- If you have a settings file to import, which might be called
Settings
We’re going to set up how IDEA works with Scala code now.
- Go back to the Configure menu on the Welcome panel.
- In the remainder of these instructions it would be a good idea to press the Apply button after each screen, because accidents happen.
- You need to define a default project JDK before you can configure Scala. To do that:
- Select Structure for New Projects, which defines defaults for new projects, and you should see:
- The Project menu item will automatically be selected.
- Ensure that the Project SDK pull-down has a valid value. If not, select a valid value from the pull-down menu.
- If none of the menu items are valid, or there are no menu items, click the New... button to the right of the pull-down menu and navigate to the directory where you installed the JDK you wish to use.
- For Mac this will be a path like
/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/Home
. - For Ubuntu Linux, this will be under
/usr/lib/jvm
. Wait a few seconds and this selection should automatically appear. - For Windows you should use a 64 bit Java compiler, which defaults to a directory like
C:\Program Files\Java\jdk1.8.0_71
.
- For Mac this will be a path like
- For Project language level I selected 8 - Lambdas, type annotations, etc. You might want to do the same for Scala 2.12; Scala 2.13 seems like it should work with JDK 8 onwards.
- Ensure the Platform Settings / SDKs menu item selects the same JDK you just selected in the previous step.
- If not, click the green + JDK menu item and select the same JVM as before.
- Click OK.
- Select Structure for New Projects, which defines defaults for new projects, and you should see:
- Back at the Welcome panel, define global settings by clicking on Configure / Settings.
- The Default Settings panel will open.
-
Navigate to Editor / Code Style / Scala / Imports.
- Unset Use the shortest path, when trying to import references with already imported name because that setting can get you into trouble when you optimize imports.
- Set Add fully qualified imports.
- Set Add import statements in closest block
- I set Class count to use import with ’_’: to 9999 because I like explicit imports.
- Version Control – Enable Show directories with changed descendants.
- Git.
-
Create a new file called something like
C:\wsl\git.bat
, containing this content: -
Set Path to Git executable to the full path of the script, for example
C:\wsl\git.bat
-
Click Test to see if IDEA found the git executable. You should see something like:
-
Create a new file called something like
- Git.
- Build, Execution, Deployment
- Build Tools / sbt – these are global settings for all
sbt
projects.You can tell this is so because:- The top says in faint lettering: For new projects.
- The section labeled Linked sbt projects merely says "Nothing to show"
- The Project-level settings area is empty.
The next lecture, Working With IntelliJ IDEA, discusses the additional controls that appear in this dialog panel when applied for specific projects.
- Build Tools / sbt – these are global settings for all
- Compiler
- It is safest (but a bit slower) to enable Clear output directory on rebuild.
- You should enable Compile independent modules in parallel.
- The default Compiler process heap size (Mbytes) of 700MB is for non-Scala compilers. This memory is allocated on first use, so you can ignore this setting.
- Scala Compiler - You can select the incremental compiler setting of your choice; I use the default, which is IDEA. Here is some background. The other settings in this dialog are only applicable to projects created by IDEA, not from SBT files. These settings will be overridden by SBT project settings.
- Scala Compiler / Scala Compile Server: Increase JVM maximum heap size, MB to a large value. The size depends on the size of the projects you work on. My settings are shown, and if you have a lot of RAM (I have 32GB RAM on my laptop) you should use it.
- Ensure the JDK is the same JDK you set previously.
- Set JVM maximum heap size, MB to at least 4096; more is better for large projects. This memory is used to convert the IDEA project model to something compatible with the Zinc server, and to parse error messages from the compiler. The lifespan of this memory allocation is only during a compilation, so if you did not specify the Zinc server in the previous dialog this value is not important.
- Bytecode Indices.
This dialog box is for people with too much time on their hands.
If you enjoy tinkering, check it out after working through the lectures in this course entitled
SBT Global Setup,
SBT Project Setup and
SBT Tasks and Settings.
Note the comments, which were written for project that use SBT 0.1.3. Other versions of SBT are also supported, as you can see from the GitHub repo:- Add the following line to
project/plugins.sbt
:addSbtPlugin("org.jetbrains" % "sbt-idea-compiler-indices" % "0.1.3") // Version "1.0.0" is also available
- Add the following line to
build.sbt
:ideaPort in Global := 65337
- Add the following line to
- Language & Frameworks / Scala
- Editor
- Enable Show type info on mouse hover, after ms (might be annoying, however)
- Ensure Highlight implicit conversion is enabled.
- Enable Highlight arguments to by-name parameters and the sub-items Include block parameters and Include literals.
- Enable Custom scalaTest keywords highlighting.
- Disable Add override keyword to method implementation (this is my personal choice; your coding conventions might differ).
- Worksheet tab
- Treat .sc files as: This pull-down menu forces you to apportion tasks between Scala Worksheets and Ammonite, or a combination. This course has a lecture on Scala Worksheets and another lecture on Ammonite. For now, do what I do and use Ammonite for tests and goofing around. You can come back later and change this setting later.
- Set Output cutoff limit, lines to 999
- Eclipse is so suboptimal for Scala that there is not much point in enabling "Use eclipse compatibility mode".
- Leave Treat Scala scratch files as worksheet files enabled.
- Uncheck Collapse long output by default ... I find this annoying, I want to see the whole problem right away when a new problem first manifests.
- Editor
- Appearance & Behavior
-
Appearance
-
If you have not already done so, change the Theme to Darcula. IDEA will restart.
-
If you are color-blind, enable Adjust colors for red-green vision deficiency (protanopia, deuteranopia).
-
Under Window Options, enable Show memory indicator.
-
You might want to enable Small labels in editor tabs, for those times where you need a lot of files in front of you at once.
-
If your screen’s aspect ratio is 16:9 or more, enable Widescreen tool window layout.
-
-
System Settings – Set Default directory to where you normally store your code. I use
C:\work
for Windows, which maps to/mnt/c/work
in Windows Subsystem for Linux and VirtualBox’s shared folder is also/mnt/c/work
. The Windows Subsystem for Linux lecture discussed this in detail. Mac users should fill this with a value that makes sense to them.
-
-
Editor
- General - this is a huge dialog, and you will have to scroll down to find some of these settings. I was not able to expand it large enough to provide a screen shot that shows it all.
- Enable Change font size (Zoom) with Ctrl+Mouse Wheel.
- Keep Allow placement of caret after end of line deselected.
- Enable Allow placement of caret inside tabs.
- You might want to select Show quick documentation on mouse move at first, while you are learning IDEA. Later on, those documentation panels become quite annoying, so come back and turn them off here.
- Enable Highlight current scope so you can easily recognize what scopes look like.
- If you want the background color and font colors to be preserved when pasting code from the editor to an rich editor, such as most email editors, keep Copy as rich text by default enabled. You can also select various color schemes to be pasted if you wish.
- Appearance - Ensure Show line numbers is enabled.
- Editor Tabs
- If your monitor has a 16:9 or 16:10 aspect ratio, you may want to maximize the use of the vertical dimension for your editor. In that case, set Editor Tab Appearance / Placement to Left or Right. To help you decide, this is what an IDEA project looks like with the default tab (Top) placement:
This is what the Right tab placement option looks like:
- To disable the Scala type popup display, deselect n / autopopup in (ms). I suggest you leave it alone for now, and only modify if you find this annoying.
- Enable Show file extension.
- Enable Mark modified (*).
- Enable Open declaration source in same tab.
- If your monitor has a 16:9 or 16:10 aspect ratio, you may want to maximize the use of the vertical dimension for your editor. In that case, set Editor Tab Appearance / Placement to Left or Right. To help you decide, this is what an IDEA project looks like with the default tab (Top) placement:
- Smart Keys
- Reformat block on typing ’}’ – You may want to come back to this setting later. I usually find I am happy with the default setting, which causes code to be reformatted whenever you type a closing
}
character. However, sometimes you want your code to remain exactly as it was instead. For those circumstances, or if you prefer, uncheck this option. - I like to deselect Insert pair ’}’ because I always find myself deleting the matching brace.
- Reformat block on typing ’}’ – You may want to come back to this setting later. I usually find I am happy with the default setting, which causes code to be reformatted whenever you type a closing
- Color Scheme ensure Scheme Darcula is selected.
- Inspections
- If you might ever want to work with Play Framework, turn the following warning off:
-
HTML / File reference problems (so Play Framework templates do not have a lot of complaints over missing files)
-
-
Enable this sbt warning: Replace
project()
withproject.in()
-
Set these Scala warnings:
-
Enable: General / Relative import\
-
Disable: Method signature / Method with Unit return type has functional definition
-
Enable: Method signature / Method with Unit return type has procedural definition
-
Enable: Method signature / Method declaration has no explicit return type
-
- If you might ever want to work with Play Framework, turn the following warning off:
- General - this is a huge dialog, and you will have to scroll down to find some of these settings. I was not able to expand it large enough to provide a screen shot that shows it all.
- Keymap
- If you are used to the Eclipse IDE’s shortcut keys, you can use them with IDEA by setting them from Keymap / Keymaps. To do this, select the predefined Eclipse key map. Unless you and your entire team are committed to programming exclusively on the Mac, I suggest you do not use the Eclipse Mac key bindings, because they do not map to Linux or Windows key bindings for Eclipse. In fact, because I so rarely encounter Eclipse, and because IDEA’s tools for working with custom key bindings are rather rudimentary, I now recommend that most people should go with the Default keymap.
-
You can define additional key bindings. I find it useful to bind Alt-H to View Local History. This allows me to view the change history for the currently edited file in the IntelliJ historical comparison window. Here is an example of what a historical comparison window looks like (notice that I set Ignore whitespace to All):
To create the key binding, typehistory
into the keymap filter as shown below, then select Main menu / VCS / Local History / Show History. Double-click or press Enter and the Edit Shortcuts popup menu appears.
Press Enter or click on Add Keyboard Shortcut and then press the key combination that you would like to bind to this action, for example, Alt-H. -
-
Another key binding I like to setup allows you to move easily between IDEA tab groups. I like binding to Ctrl-Alt-Shift-PgUp and Ctrl-Alt-Shift-PgDn:
- If you are used to the Eclipse IDE’s shortcut keys, you can use them with IDEA by setting them from Keymap / Keymaps. To do this, select the predefined Eclipse key map. Unless you and your entire team are committed to programming exclusively on the Mac, I suggest you do not use the Eclipse Mac key bindings, because they do not map to Linux or Windows key bindings for Eclipse. In fact, because I so rarely encounter Eclipse, and because IDEA’s tools for working with custom key bindings are rather rudimentary, I now recommend that most people should go with the Default keymap.
-
Tools / Terminal / Shell Path (For Windows users only that installed the Windows for Linux Subsystem): set this value to
C:\Windows\sysnative\bash.exe
. Thesysnative
virtual directory is described in this article. If it does not work, useC:\Windows\System32\bash.exe
-
Click on the OK button in the Settings dialog
Invalid JDK Settings
If you ever have a strange problem with IDEA when working with a project, check that the JDK settings are correct in all the following places. These can get out of whack when Java automatically updates.
- Configure / Project defaults / Project Structure / Project / Project SDK
- Configure / Project defaults / Project Structure / SDKs
- Configure / Settings / Languages & Frameworks / Scala Compile Server / JVM SDK (if Use external compile server for scala is enabled)
Each IDEA project can override the default JDK setting. To change the JDK for a specific IDEA project, open the IDEA project and select File / Project Structure / Project / Project JDK.
Overriding IDEA Settings
You can use jvisualvm
, provided with the Java Development Kit, to measure memory usage of the IDE, so you can optimize the memory settings. The VisualVM site has many articles that discuss how to use the tool. I suggest that you do not use the VisualVM IDE plugin to measure the IDE that it runs from, and instead run the tool standalone!

Selecting Edit Custom VM Options... from the IDEA Configure menu on the home screen brings up a pane where you can edit exactly the settings you wish to override. Here are my settings (since JDK 8 I no longer specify -XX:MaxPermSize
). I require IDEA to initially grab 128MB RAM, and use up to 4GB RAM as required.
-Xmx4G
You should provide much bigger values if you have a large project:

This configuration will persist even after IDEA updates.
I suggest you add one more custom VM option while we are here. The IDEA Markdown plugin has a known problem rendering at high quality, and this is the fix:
-Dsun.java2d.uiScale.enabled=false
Launching IDEA from WSL
Windows Subsystem for Linux is headless, and does not perform well when running a desktop like Gnome, KDE, etc, so JetBrains Toolbox is not an option for WSL users. Instead, you must launch IDEA using a script. This is my script. Note the line in idea2
that must be updated to point to the directory where you installed IDEA into.
Adding Context Menu Items(Supplemental)
Ubuntu / Nautilus
Instructions are here.
XUbuntu / Thunar
The Thunar file manager used by XFCE4 can be configured very easily.



Now whenever you right-click on a directory or file you will see a menu item called Open with IntelliJ IDEA.
Windows
Here is the .reg
file that I use to create the necessary Windows registry entries that cause menu items entitled "Open with IntelliJ IDEA" to appear in File Explorer when I right-click on a directory. I also provide a .reg
file to remove the registry entries.
These files work with all versions of Microsoft Windows, from Windows XP through Windows 10.
Not sure why the reg files are displayed with 4 backslashes - the gists are correct with only 2 backslashes.
To learn more, see How to Add Any Application Shortcut to Windows Explorer’s Context Menu
© Copyright 1994-2024 Michael Slinn. All rights reserved.
If you would like to request to use this copyright-protected work in any manner,
please send an email.
This website was made using Jekyll and Mike Slinn’s Jekyll Plugins.