Install IntelliJ IDEA on Raspberry Pi
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).
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.
Some of the commands will require root privileges, so either login as root user or use sudo to start an interactive shell via
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:
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
Create a directory to hold the 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:
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
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.
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.
It’s possible to download IDEA distributive (for Linux) directly to Raspberry Pi (consider using the latest version):
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
Mark the binary as executable:
chmod +x fsnotifier
You may test fsnotifier to ensure that it works correctly:
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:
And add the following line:
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).
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.
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
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 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:
Reboot the device and ensure that these options are applied by checking the output of
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
/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
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.
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
* Raspberry Pi is a trademark of the Raspberry Pi Foundation