Difference between revisions of "RPi Java"

From eLinux.org
Jump to: navigation, search
(Created page with "Category:RaspberryPi == General tips == Some general tips about Java perfomace on Raspberry Pi. === System memory === Java loves memory. If you do not plan to use deskto...")
 
(OpenJDK)
 
(2 intermediate revisions by 2 users not shown)
Line 12: Line 12:
 
=== Overclocking ===
 
=== Overclocking ===
 
Consider CPU overclocking with <code>sudo raspi-config</code> for considerable performance boost.
 
Consider CPU overclocking with <code>sudo raspi-config</code> for considerable performance boost.
 +
 +
== Installing Java on Raspberry Pi ==
 +
 +
=== OpenJDK ===
 +
OpenJDK is available from the Raspbian package repository.
 +
 +
<pre>
 +
sudo apt-get update
 +
sudo apt-get install openjdk-7-jdk
 +
</pre>
 +
 +
A complete list of Rasbian OpenJDK packages and OpenJDK JVM options are found at:
 +
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=27805
 +
 +
=== 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 [http://jdk8.java.net/fxarmpreview/ 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:
 +
<pre>
 +
# 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
 +
</pre>
 +
 +
*Edit <code>sudo nano -w /etc/profile</code> and add these lines to the end of file:
 +
<pre>
 +
PATH="$PATH":/opt/jdk8/bin
 +
JAVA_HOME=/opt/jdk8
 +
</pre>
 +
 +
* Logout and re-login via SSH. Run <code>java -version</code> to see if java is working. You should see something like:
 +
<pre>
 +
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)
 +
</pre>
 +
 +
* Congratulations!

Latest revision as of 04:37, 9 April 2013


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.

Overclocking

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

Installing Java on Raspberry Pi

OpenJDK

OpenJDK is available from the Raspbian package repository.

sudo apt-get update
sudo apt-get install openjdk-7-jdk

A complete list of Rasbian OpenJDK packages and OpenJDK JVM options are found at: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=27805

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 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:
PATH="$PATH":/opt/jdk8/bin
JAVA_HOME=/opt/jdk8
  • 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!