Install IntelliJ IDEA on Raspberry Pi

Raspberry Pi and IntelliJThis article shows how to install IntelliJ IDEA on Raspberry Pi. The instructions are also applicable for other IDEA-based IDEs like PyCharm, RubyMine, PhpStorm, WebStorm, CLion, etc.

At first, the idea of installing a full-fledged, contemporary IDE on Raspberry Pi may seem unrealizable. Raspberry Pi boards are incredibly small, so it’s hard to believe that those devices are apt for such a task. Nevertheless, in reality, Rasperry Pi can do much, much more than blinking a LED.

After trying out Scala on Raspberry Pi for some time, I configured my Rasperry Pi to run IDEA & Scala plugin for the recent ScalaDays conference. While it was initially intended to be just a “proof of concept”, it turned out that we were able to open the Scala plugin project itself (which is pretty large, and includes all IDEA CE sources) and to comfortably use this setup for most feature demonstrations. Obviously, it’s unreasonable to expect desktop-like performance from such a device, however I happen to successfully use a similar environment on EEE PC which was hardly faster.

The instructions rely on the following keystones that make the undertaking possible (and even practical):

  • Raspberry Pi 2 Model B, which offers a 900MHz quad-core CPU and 1GB of RAM (this one is for the “practical” part, yet you may try to use Rasperry Pi 1 as well).

  • Oracle JDK 8 for ARM (with HardFP, JIT and server VM), which provides >10X performance boost (comparing to Zero VM from OpenJDK).

  • Small, but essential modifications that enable IntelliJ IDEA to run on ARM systems, like Raspberry Pi (you may use the same techniques for other ARM-based microcomputers).

Update: we’ve fixed the incompatibilities, so IDEA 15 (or later) should be able to run on ARM architecture (including RaspberryPi) out-of-the-box.

Contents:

  1. Installing Java
  2. Installing IDEA
  3. Tweaking Raspberry Pi
  4. Tweaking IDEA

Some of the commands will require root privileges, so either login as root user or use sudo to start an interactive shell via sudo -i.

Installing Java (optional)

While IDEA platform itself depends on JVM runtime, this step is only needed if you plan to use JVM-based languages (like Scala, Clojure, Kotlin, etc.). Otherwise, you may simply extract the downloaded Oracle JDK to jre subdirectory within IDEA installation (see below), and IDEA will use it as a bundled runtime.

Some Linux distributives come with JVM pre-installed, however that JVM is usually provided by OpenJDK package. While I really appreciate that open-source implementation of the Java Platform, it currently offers no just-in-time compiler on ARM systems, so it’s too slow for our purpose.

Linux distributives often provide dedicated utilities (e. g. in Debian, in Arch Linux, etc.) to switch Java implementations, yet we’ll not rely on them and will use plain and simple approach (which is also distributive agnostic).

We can determine installed Java version by running:

java -version

If the output is “command not found” than there’s no Java installed (preferable). If the output contains “Zero VM” or “interpreted mode”, it’s better to use package manager to remove all existing Java packages (*jdk, *jre) from the system before proceeding.

First, we need to obtain JDK 8 for ARM from Oracle’s site. Open the page in a browser, accept the license and download the distributive.

Then upload the file to your Raspberry Pi via SSH (use appropriate version / host / user parts):

scp jdk-8u33-linux-arm-vfp-hflt.tar.gz user@address:/home/user

On Windows, it’s possible to use pscp from Putty for that purpose. Alternatively, you may simply copy the file to the boot partition on the SD card (which uses Windows-friendly, FAT file system) and then access the file via /boot/... path.

Create a directory to hold the JVM:

mkdir /usr/lib/jvm

Unpack the distributive:

tar -xf jdk-8u33-linux-arm-vfp-hflt.tar.gz -C /usr/lib/jvm

Rename the resulting directory:

mv /usr/lib/jvm/jdk1.8.0_33 /usr/lib/jvm/java-8-oracle

Delete the original archive file:

rm jdk-8u33-linux-arm-vfp-hflt.tar.gz

Create symbolic links to binaries:

ln -s /usr/lib/jvm/java-8-oracle/bin/java /bin/java
ln -s /usr/lib/jvm/java-8-oracle/bin/javac /bin/javac

Run java -version again, the output should be like:

java version "1.8.0_33"
Java(TM) SE Runtime Environment (build 1.8.0_33-b05)
Java HotSpot(TM) Client VM (build 25.33-b05, mixed mode)

This confirms that the required version of Java is correctly installed.

Installing IDEA

To install IDEA on Raspberry Pi, we need to extract the distributive, update a native file system watcher binary and to select a proper file system access layer.

Installing distributive

It’s possible to download IDEA distributive (for Linux) directly to Raspberry Pi (consider using the latest version):

wget https://download.jetbrains.com/idea/ideaIC-14.1.3.tar.gz

Unpack and then delete the downloaded archive:

tar -xf ideaIC-14.1.3.tar.gz -C /usr/share/
mv /usr/share/idea-IC-141.1010.3 /usr/share/idea
rm ideaIC-14.1.3.tar.gz

Create a symbolic link to start IDEA from command line:

ln -s /usr/share/idea/bin/idea.sh /bin/idea

Updating native file watcher

Next thing we need to do, is to provide an ARM binary of fsnotifier. IntelliJ IDEA relies on native file system watcher to monitor for external file changes, however the bundled binaries can work only on x86 CPUs. While it’s possible to run IDEA without fsnotifier, the native file watcher is essential to achieve optimal performance.

As IDEA is open-source, we can always compile fsnotifier for ARM. Yet, if you don’t want to tinker with the compilation, you may simply download a prebuilt fsnotifier ARM binary and place it in idea/bin subdirectory, replacing existing fsnotifier and fsnotifier64 files.

Mark the binary as executable:

chmod +x fsnotifier

You may test fsnotifier to ensure that it works correctly:

./fsnotifier --selftest

The output should contain no errors or warnings.

Configuring file metadata access

Another obstacle to overcome is an incompatibility in IDEA’s JnaUnixMediatorImpl code (which we need to fix have fixed in future builds), preventing IDEA to determine file length correctly (so that IDEA throws “Premature End Of File” exceptions).

We need to explicitly tell IDEA to rely on NIO 2 implementation (which is compatible with Raspberry Pi architecture).

Open IDEA VM options:

nano /usr/share/idea/bin/idea.vmoptions

And add the following line:

-Didea.io.use.nio2=true

Optionally, you may delete -XX:MaxPermSize=250m line (this option is deprecated in Java 8), and also delete -Dsun.io.useCanonCaches=false line (to improve performance). If you try this on Raspberry Pi 1 (which uses ARM6 CPU), don’t forget to remove -server line, because server VM relies on ARM7 processor.

Providing X server

Apparently, IDEA’s GUI needs X Window System to run. If your Linux distributive comes with desktop environment (like Xfce, Mate, LXDE, etc) pre-installed, then you should already have X server, otherwise (if your system has only bare command line) you need to setup a minimal X Window system to display the UI (you may simply install LXDE which includes X.Org server as a dependency).

While it’s possible to use X11 forwarding over network to a remote X server (including Xming on Windows and XQuartz on Max) for headless Raspberry Pi configurations, I still recommend to use local X server via VNC instead (e. g. TightVNC or TigerVNC), because X protocol is too chatty and can cause a lot of UI freezes (VNC, on the contrary, works flawlessly with IDEA).

Installing fonts

As a finishing touch, it makes sense to install a decent font package (like DejaVu, etc.) via a package manager. Personally, I prefer to use Microsoft TTF fonts (for Raspbian, for Arch Linux) with -Dawt.useSystemAAFontSettings=on line in the idea.vmoptions file to disable sub-pixel antialiasing.

Starting up

Now it should be possible to run IDEA either from command line, by typing idea (useful to check for possible startup error), or from a desktop environment, by creating a shortcut for /usr/share/idea/bin/idea.sh.

Despite that Raspberry Pi & IDEA combo works surprisingly well “as is”, you may consider applying some tweaks to improove performance further.

Tweaking Raspberry Pi (optional)

There are multiple ways to speed up and optimize Raspberry Pi for running IntelliJ IDEA — from hardware tweaks, to OS configuration.

Overclocking

Overclocking provides immediate, substantial performance boost.

To overclock your Raspberry Pi, open /boot/config.txt file (more info) and uncomment lines in a desired overclocking section, like “Modest”, “Medium”, “High”, “Turbo” (by remove leading # chars), and then reboot the device. On Raspbian you may run raspi-config utility for that purpose.

If everything works fine, you may try the next level, otherwise revert the changes back (you may do that even from Widows, by opening config.txt on SD card).

My Raspberry Pi 2 (Model B) board works fine with:

arm_freq=1000
core_freq=500
sdram_freq=450
over_voltage=6

If you prefer to overclock Raspberry Pi, it’s a good idea to install a heatsink on the device and to use a power adapter that can provide at least 1A current (2A is even better). Also, mind the USB cable quality.

Optimizing file system

Another way to speed up things, is to improve file system performance.

First, make sure that you are using a reasonably fast SD / microSD flash memory card (mine is Samsung 32GB EVO microSD Class 10, which performs really well). You may refer to SD card benchmarks topic on the Raspberry Pi forum (prefer fast random access rather than throughput).

Then, make sure that your file system is ext4 and upgrade the file system if needed. It seems counterintuitive, yet ext4 (with journaling) perform better than, for example ext2 (which doesn’t use journaling). You may use mount command to see which file systems are currently in use.

By default, Linux stat system call writes data to disk on (almost) all file metadata queries (to update file “access time”). Such a behavior might significantly degrade file system performance, especially on slower storage devices (like SD flash cards). It’s possible to use noatime mount option to disable access time updates.

Some Linux distributives for Raspberry Pi apply noatime option out-of-the-box, so call mount to determine whether it is already used. Here’s how you can add the option to /etc/fstab (mind the device name):

/dev/mmcblk0p2 / ext4 defaults,noatime 0 1

After a reboot, use mount command to verify that the option is applied.

To improve file system writing speed, you may consider removing write barrier (though this reduces data safety in case of crash or power loss).

To do that, open /boot/cmdline.txt and add the following options:

rootflags=data=writeback,barrier=0

Reboot the device and ensure that these options are applied by checking the output of mount command.

Configuring swapping

Because IDEA and external tools (like build managers, compilers, etc.) might use a lot of RAM (however, they rarely actively use RAM simultaneously), it makes sense to enable swapping to facilitate optimal memory allocation and to avoid “out-of-memory” errors.

Some distributives come with swapping pre-configured, so use swapon -s to determine whether that is the case (also make sure that swap size is at least 1 GB).

To enable swapping, we need to allocate a file, create a proper file system on it and then tell OS to use this file as a swap:

fallocate -l 2G /var/swap
chmod 600 /var/swap
mkswap /var/swap
swapon /var/swap

To make this persistent, add the following line to /etc/fstab:

/var/swap   none    swap    sw    0   0

Configuring clock synchronization

IDEA relies on file modification timestamps for indexing / incremental compilation, yet Raspberry Pi boards have no real time clock (RTC), so they reset OS time on boot.

Most distributives use NTP to synchronize clock over the Internet. Make sure that the synchronization works properly by issuing date command.

Alternative, more “geeky” option is to connect a real time clock to Raspberry Pi.

Tweaking IDEA (optional)

Default IDEA settings are hardly intended for microcomputers, so we can switch off a few things to make the UI more responsive:

  • Appearance / Animate windows
  • Editor / General / Smooth scrolling
  • Editor / Code Completion / Autopopup
  • Editor / Parameter Info / Autopopup

However, these checkboxes at your option, because IDEA runs fine even with the default settings.

What I highly recommend is to enable zero-latency typing in IntelliJ IDEA to get a much better typing experience. This mode makes a huge difference on entry-level hardware.

Additionally, you may review the list of plugins, inspections and intentions to enable only those that are really needed.

See also: Install Scala on Raspberry Pi

* Image background is a crop from glowing raspberries by Samantha Forsberg, licensed under CC BY 2.0

* Raspberry Pi is a trademark of the Raspberry Pi Foundation

15 Comments

  1. spin3llo says:

    Amazing guide, thank you!

  2. jvidin says:

    Hello Thank you for the guide ,
    Im trying to install pycharm 5 community on my pi2 , follwed all the steps , there was one first tentative that i was able to select the theme Dracula but since that try unfortunately its getting me always the error below : any suggestions .
    :using xming server on windows via putty.

    pi@raspberrypi /boot $ pycharm
    WARN: Connection refused
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.(Socket.java:434)
    at java.net.Socket.(Socket.java:244)
    at com.intellij.idea.SocketLock.tryActivate(SocketLock.java:184)
    at com.intellij.idea.SocketLock.access$300(SocketLock.java:50)
    at com.intellij.idea.SocketLock$2.call(SocketLock.java:124)
    at com.intellij.idea.SocketLock$2.call(SocketLock.java:113)
    at com.intellij.idea.SocketLock.underLocks(SocketLock.java:157)
    at com.intellij.idea.SocketLock.lock(SocketLock.java:113)
    at com.intellij.idea.StartupUtil.lockSystemFolders(StartupUtil.java:263)
    at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:101)
    at com.intellij.idea.MainImpl.start(MainImpl.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:90)
    at java.lang.Thread.run(Thread.java:744)
    log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

  3. Jay says:

    Thank you for the article. I have a Raspberry Pi 2 and I tried installing intelliJ IDEA. The version I was installing was 15.0.3. I am getting stuck at this part. Please help me

    tar -xf ideaIC-14.1.3.tar.gz -C /usr/share/
    mv /usr/share/idea-IC-141.1010.3 /usr/share/idea
    rm ideaIC-14.1.3.tar.gz

  4. Pavel says:

    Hi jvidin,

    Please make sure that the IDE is started with Oracle’s JDK (check “java -version” output, or just extract the downloaded JDK to “jre” sub-directory inside the PyCharm installation).

    I highly recommend to use VNC instead of X11 forwarding, as VNC provides much better performance in this case. I also recommend to enable zero-latency typing mode in PyCharm for better typing experience (more info).

    If the application freezes at the start after some tweak, you may always reset the configuration to its initial state by deleting “~/.PyCharm*” settings directory.

  5. Pavel says:

    Hi Jay,

    IDEA 15+ should work on ARM (and so on Raspberry Pi) out of the box, so it should be enough to simply extract the IDEA archive and provide the Oracle JDK.

    Just use actual version number in the commands, i.e. “15.0.3” instead of “14.1.3”.

    It’s also possible to extract the archives using GUI tools, or even a separate Linux machine. There’s no need to use the command line, all you need to do is to extract the IDEA and the JDK archives, and to place the JDK files inside “jre” sub-directory of IDEA installation.

  6. Richard says:

    wget https://download.jetbrains.com/idea/ideaIC-14.1.3.tar.gz

    I get a 403 error. Is is password locked

  7. Pavel says:

    The URL has changed, actual URLs for previous releases are listed at https://confluence.jetbrains.com/display/IntelliJIDEA/Previous+IntelliJ+IDEA+Releases.

    It’s probably better to download the newest version of IDEA from https://www.jetbrains.com/idea/download/#section=linux as it’s already adapted for ARM architecture and it should work on Raspberry Pi out of the box (since IDEA 15), providing that you have Oracle JDK installed.

  8. tatery says:

    Hi,

    Thanks for this guide. You make life easier for many people 😉 however IDEA took a lot of Raspberry Pi resources
    – RAM: almost 500M
    – processor time: very often 100% (CPU overclocked to 1300)
    – startup time with simple maven project: 3min
    – opening some application options took ages (like in pentium III)
    In my opinion, with current application response time it is hard to work with it on Raspberry Pi3. For comparison try to use eclipse from official Raspberry repository – it works quicker however does not support java 1.8

    Details about my configuration:
    Linux raspberrypi 4.4.21-v7+ #911 SMP Thu Sep 15 14:22:38 BST 2016 armv7l GNU/Linux

    model name : ARMv7 Processor rev 4 (v7l)
    BogoMIPS : 83.20
    Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x0
    CPU part : 0xd03
    CPU revision : 4

    Hardware : BCM2709
    Revision : a02082

    IntelliJ IDEA 2016.2.5
    Build #IC-162.2228.15, built on October 14, 2016
    JRE: 1.8.0_65-b17 arm
    JVM: Java HotSpot(TM) Server VM by Oracle Corporation

  9. Pavel says:

    Last time I checked, IDEA was surprisingly responsive, but that was with IDEA 14 / 15 on Raspberry Pi 2.

    You may try to tune memory-related properties in idea.vmoptions (e.g. reduce the heap size, for a start). Additionally, you may try to disable swapping (if configured) to check whether there is a RAM bottleneck.

  10. tatery says:

    I tweaked more IDEA options than you mentioned and now it is quite responsive but it looks not so nice like before and I missed some features. The best solution would be to have IDE on PC and have a possibility to debug remotely with “one click”. I know there is a plugin for embedded debugging (https://plugins.jetbrains.com/plugin/7738?pr=objc) however with it I’m not able to debug maven projects with different build goals (for example test goal driving TestNg).

    BTW, I cannot select debugging with shared memory on RPi. Do you have any idea why it is not available?

  11. Peter K says:

    I actually got it to start up.
    But with latest intellij when it gets to the “import, create new, open existing” panel it initializes the directory browser with ‘/’ ( root folder ) and then freezes and the only way out is to ^C from the launching command line.

    I have an existing project I checked out from git that I want to open to test it.

    I tried running it both from my user and from root. And in my ~/code/intellij-project directory containing the project and not.

  12. Pavel says:

    Hi Peter,

    There’s probably some error in IDEA, yet it’s suppressed by default.

    To investigate the problem, you may try to check ~/.Idea*/system/log/idea.log file for errors.

    Alternatively, it’s possible to set idea.fatal.error.notification=true in bin/idea.properties file, so that IDEA will display errors in the UI.

  13. amd says:

    hi pavel.. I’m trying to run intellij Idea 2018.1 community on raspberry 2 (on raspbian stretch) .. it starts .. but terminal doesn’t work … can you help me for this ?

  14. Xabaras says:

    If I try to download and run the prebuilt fsnotifier from your link I get the folllowing error:

    $ ./fsnotifier
    -bash: ./fsnotifier: No such file or directory

    any advice?

    Thanks in advance

  15. Pavel says:

    The file might be downloaded incorrectly, might have no “x” permission(s), or might not match the machine architecture (such as AArch64).

    Make sure that the file exists and has “x” permissions:
    ls -l fsnotifier

    Then check the file type:
    file fsnotifier

    To see more details, you may also use:
    readelf -h fsnotifier

    Make sure that the architecture matches your machine:
    uname -a