Installation and upgrade
curl -o intellij-idea.tar.gz -L https://download.jetbrains.com/idea/ideaIC-2020.1.tar.gz mkdir -p /opt/idea tar -C /opt/idea -xvf intellij-idea.tar.gz
An example entry for the GNOME Applications menu - note the reference to the startup script,
$ cat ~/.local/share/applications/jetbrains-idea-ce.desktop [Desktop Entry] Version=1.0 Type=Application Name=IntelliJ IDEA Community Edition Icon=/opt/idea/idea-IC-201.6668.121/bin/idea.png Exec="/opt/idea/idea-IC-201.6668.121/bin/idea.sh" %f Comment=Capable and Ergonomic IDE for JVM Categories=Development;IDE; Terminal=false StartupWMClass=jetbrains-idea-ce
To add a symlink (so you can easily start IntelliJ from the terminal on Linux):
$ sudo ln -s $IDEA_HOME/bin/idea.sh /usr/local/bin/idea # Then you can run using: # cd myproject && nohup idea . &
Nice keyboard shortcuts
- Select In: Alt+Shift+1. To quickly select the current element in any view (Project view, Maven view, etc.)
- Quick Documentation: Ctrl+Q. To view documentation for whatever object (class, type, etc.) currently at the caret.
Working with version control systems
Useful process for larger projects:
- Open the Version Control window using View > Tool Windows > Version Control.
- Click Local Changes to show local changes (which will include conflicts)
- Click the gear icon and Group By either Directory or Module (makes it easier to just work on merge conflicts in a specific directory or module)
Debugging unit tests using IntelliJ
- Create a new Run Configuration in IntelliJ.
- Set the command line property to your test Maven goal name, e.g.
- On the Runner tab, set VM Options to:
- Set any breakpoints in your code
- Now Debug your Run Configuration, e.g. Ctrl+D, or Run → Debug ‘my-app [test]’.
Debugging an external application
- Choose Run → Edit Configurations.
- Add a new Configuration of type Remote. Name it debugging.
- Copy the command line arguments for running remote JVM (e.g.
- (Optional) Modify
suspend=yto make the Java application wait until the debugger is connected before starting.
- (Optional) Set the debug flags in the environment variable
- In a Terminal, start the application to be debugged.
- In IntelliJ, start the remote debugger (Run → Debug → debugging).
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -jar target/spring-boot-camel-xa-1.0-SNAPSHOT.jar
Debugging for specific tools/frameworks
Spring Boot 2.x
Since Spring Boot Maven Plugin now forks the Java process since version 2.2, debugging breakpoints won’t stop/work when running the application using the
Instead, run the application using the bootstrap class: find the
@SpringBootApplication class and just run it from the IDE (green Play button).
Thorntail Maven Plugin
Set the property
thorntail.debug.port which causes Thorntail Maven Plugin to suspend on start and open a debugger on this port (when using
start goals), e.g.:
$ mvn thorntail:run -Dthorntail.debug.port=8000
IntelliJ tries to build the entire project before running a single test:
- Run → Edit Configurations
- Navigate to JUnit → Your project, and then remove Make from the list of ‘before launch’ tasks.
Cannot resolve classes/objects/dependencies (lots of squiggly red underlines everywhere):
- Check that the project has been added as a Maven project (right-click the pom.xml → Add as Maven Project)
- Ensure that IntelliJ is using the correct Maven binary - go to Settings → Maven, and check the path to the Maven installation location, and
- Check that artifacts can be resolved correctly. Drop to a Terminal and, using the same Maven binary configured in IntelliJ, try
mvn -U help:effective-pom. If artifacts can’t be resolved here, then fix this first.
- If you’re pulling artifacts from a Nexus repository, check that it’s able to pull artifacts from the web. Log in to Nexus and check the status of your proxy repositories.
- Check that
maven-compiler-pluginis configured correctly (e.g. with a version number)
Package names aren’t resolving (classes can’t see other classes, etc.):
- Check that the
testfolders have been added as Sources
- Right-click the
src/main/javafolder, right-click → Mark Directory as → Sources Root
- Right-click the
src/test/javafolder, right-click → Mark Directory as → Test Sources Root
XML Schema URLs are appearing in red in the XML editor:
- IntelliJ doesn’t know how to resolve the XML schema definition (XSD)
- If one of your Maven dependencies contains the XSD file already inside the JAR, then IntelliJ will use that.
- The red error highlighting indicates you either need to add a Maven dependency which contains the missing XSD, or you need to download the resource manually.
- Ctrl+hover over an XSD which is valid, and you’ll see the path that IntelliJ has resolved to the XSD file (e.g. if it’s been resolved from a Maven dependency, it’s a
- Hover around the red text and wait for the Intention (light-bulb icon) and choose the command Fetch external resource
- See also: Map External Resource feature - which allows you to map a URI to a file inside a JAR manually.
- See also: Settings -> Resources where you can map URIs to physical files on disk manually.