RPi Java

From eLinux.org
Revision as of 15:27, 22 February 2013 by RxS-pi (talk | contribs) (General tips)
Jump to: navigation, search

General tips

Some general tips about Java perfomace on Raspberry Pi.

System memory

Java loves memory. If you do not plan to use desktop enviroment / XBMC run sudo raspi-config select memory_split and decrease GPU memory to 16. You'll get more than 100 Mb of additional system memory.

Swap file

Do not swap! Manage your JVM memory consumption with -ms and -mx keys. If you absolutely have to swap move swap file (/var/swap) to USB HDD of fast flash drive because swapping to SD card is painfully slow. You can set swap size in /etc/dphys-swapfile config file.


Consider CPU overclocking with sudo raspi-config for considerable performance boost.

Installing Java on Raspberry Pi

Oracle Java 8

Oracle JDK 8 for ARM has JIT compiler and supports hard float point instructions. This is the fastest (1.5x-10x times faster than other JVMs) Java option for Raspberry Pi. Please note that Java 8 is still in beta stage and may be less stable than Java 7. You can install it on standard Raspbian system.

  • Login to you Pi via ssh and run:
# you download link from step 1
wget http://www.java.net/download/JavaFXarm/jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
tar zxf jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
rm zxf jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
sudo mv ./jdk1.8.0/ /opt/
sudo chown root:root -R /opt/jdk1.8.0/
sudo ln -s /opt/jdk1.8.0/ /opt/jdk8
  • Edit sudo nano -w /etc/profile and add these lines to the end of file:
  • Logout and re-login via SSH. Run java -version to see if java is working. You should see something like:
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)
  • Congratulations!