Some general tips about Java perfomace on Raspberry Pi.
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.
Do not swap! Manage your JVM memory consumption with
-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.
- Visit JDK 8 for ARM Early Access web site, accept License Agreement, right click and copy download link.
- 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 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
sudo nano -w /etc/profileand add these lines to the end of file:
- Logout and re-login via SSH. Run
java -versionto 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)