IntelliJ

Overview

InjelliJ has good support for maven. It is very easy to run all the maven lifecycle phases from within the IDE - which makes it very convenient during the development process.

Eclipse has the same convenient features - with the installation of a plugin. Look at the Eclipse Tips document for more details. But working with maven is not as easy in Eclipse.

Installation

Different ways to install in Arch Linux:

  1. Installing different products from Jetbrains

    1. This is the preferred way
  2. Get it from AUR - simple and also easy to upgrade later, but may cause breakage. Search for it and then pick the appropriate one.

    may sometimes break during pacman version upgrades

    paru -Ss intellij
    
  3. Get it from flathub - flatpak seems like the correct option for installing heavy apps.

Which option is the best?

  1. Even though installing directly grom AUR should not cause any breakages (the AUR packages follow the official well tested stable releases), I have seen instances when this happened. All of a sudden, the IDE will not start and throw error like this: java.lang.RuntimeException: Could not find installation home path. Please make sure bin/idea.properties is present in the installation directory.
  2. Use the toolbox. Easy and simple. Make sure you configure it to install in /opt not /home

Themes and Customization

Themes

  1. Xcode Dark (with font size increased to 13)
  2. https://plugins.jetbrains.com/plugin/17004-eclipse-plus-theme

Keyboard shortcuts

  1. To go to the start or end of the methods: Ctrl [ or Ctrl ]

Gotchas with IntelliJ

The refactoring capabilities are nice but we have to be very careful with it. I refactored the name of a method. This method was used in multiple projects. It renamed this method and a related method as well - leading to unintended behavior.

Renaming variable names and method names in a file is ok.

But for renaming method names, you are probably better off doing it manually.

My complaints about IntelliJ

If you stage some changes using Git in IntelliJ, when you look at the status from terminal, why doesn’t terminal reflect the updates done from IntelliJ Git? Vice versa is also an issue. If you stage some changes from terminal, whey don’t they show up as staged in IntelliJ?

Issues and debugging tips

Exception: intellij failed to resolve org.junit.platform:junit-platform-launcher:1.3.2

Option 1:

Intellij IDEA > Preferences… > Appearance & Behavior > System Settings > HTTP Proxy

Changed from No Proxy to Auto-detect proxy settings (Or, if you know the proxy settings for your company, enter them there)

Option 2:

It turns out that, junit5-platform-launcher dependency needs to be added in order for Junit5 tests to run in IntelliJ.

As a workaround, add this dependency explicitly in pom.xml, and it will solve the issue.

<dependency>
     <groupId>org.junit.platform</groupId>
     <artifactId>junit-platform-launcher</artifactId>
     <scope>test</scope>
</dependency>

You can remove the dependency from the pom.xml after IntelliJ downloads the jar successfully. This change doesn’t have to be committed to source control.

How to open multiple projects in one window in IntelliJ?

https://www.jetbrains.com/help/phpstorm/open-close-and-move-projects.html#merge-project-windows

Merge project windows (macOS)

On macOS, you can merge all opened project windows into one, turning them into tabs.

Make sure that there are several PhpStorm projects opened in separate windows.

In the main menu, go to Window | Merge All Project Windows.

Drag a project’s tab to work with the project in a separate window again.

With default macOS settings, tabs will be lost after you restart the IDE, and projects will open in separate windows. If you would like the IDE to reopen projects in tabs, configure your macOS to always use tabs when opening documents.

(This is Apple specific configuration. Not specific to IntelliJ.)

https://support.apple.com/guide/mac-help/use-tabs-in-windows-mchla4695cce/mac

Specify when to open documents in tabs

On your Mac, choose Apple menu > System Settings, then click Desktop & Dock in the sidebar. (You may need to scroll down.)

Go to Windows, click the “Prefer tabs when opening documents” pop-up menu, then choose an option.

Working with Tomcat in Intellij Idea Community Edition

Is it possible to run a web application using Tomcat Server in Intellij Idea Community Edition?

Yes, by installing Smart Tomcat plugin https://plugins.jetbrains.com/plugin/9492, make following settings. Working with the application and debugging work amazingly well.

What is context? Typically, it is the name of the application.

Build errors for applications in IntelliJ

If you can build the application from terminal but the build is failing in IntelliJ, it indicates that the settings for the application in IntelliJ are not correct. How to fix it?

In the “Maven” panel, select “Edit Run configurations” and look at the Run Configurations. Everything should be default here. Don’t use any custom parameters (like JVM options) here. Clear out any custom parameters that are set.

Where do we set custom JVM options for running applications?

When working with Smart Tomcat,

Run -> Edit Configurations -> Smart Tomcat -> <Your config for your application> -> Environment variables

It will be in the format key=value (No need to put -D at the beginning of the key).

Where are the IDEs located on my hard drive?

Windows: %LocalAppData%\Programs
macOS: ~/Applications
Linux: ~/.local/share/JetBrains/Toolbox/apps

It uses different folders for storing different settings. See https://www.jetbrains.com/help/idea/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html

Where can we find IntelliJ logs

Help -> Show Log in Explorer

TODO

https://stackoverflow.com/questions/32476228/intellij-spring-initializr-not-available