I wonder if I can use Java SE libraries (like the ones we use when designing desktop apps via Java) in Java SE embedded which can be installed on a Raspberry Pi.
Is it possible?
Yes you can.
An example is shown on Getting Started with Java® SE Embedded on the Raspberry Pi, by Bill Courington and Gary Collins.
How to get Linux and Java SE Embedded running on the Raspberry Pi in less than an hour
It is hardly larger than a credit card. It costs about the same as a book on Java programming.
It's the Raspberry Pi computer, and it can support a full Java SE runtime for headless embedded applications. This article gets you started with Java on the Raspberry Pi programming with these topics:
- The Raspberry Pi: A brief introduction
- Prerequisites: What you need to have and know
- Essential Linux Setup: How to install Debian Linux
- Java SE Embedded Setup: How to acquire and install Java SE Embedded
- Optional Linux Tuning and Tweaking: How to make Linux work better for you
NOTE: There are many potential variations of the instructions given here, especially which operations you execute on a host (desktop or laptop) computer, and which you execute on the Raspberry Pi. Use your knowledge and preferences (and perhaps some of the topics in the Optional Linux Tuning and Tweaking section) to create a workflow that works for you.
Here is the Java SE Embedded Setup:
- In the host computer’s web browser go to http://www.oracle.com/technetwork/java/embedded/downloads/javase/index.html. The web page might have changed in detail since this article was written.
- In the Java SE Embedded 7 column, click EABI, VFP, SoftFB ABI, Little Endian. A survey page appears.
- Complete the survey and click Submit. A verification page appears.
- Examine the verification page for correctness (in particular, your email address), then click Submit. In a short time, an email from JavaSE-Embedded-LinkNotify appears in your inbox.
- Click the link in the email. Another download page appears (some details might have changed since this article was written):
- Select Accept License Agreement, then click the link in the ARMv6/7 Linux - Headless row.
NOTE: At the time this article was written, the ARMv7 Linux - Headful software had not been tested on the Raspberry Pi. The ARMv7 Linux - Headless - Server Compiler software does not work on the Raspberry Pi because that software requires an ARM v7 chip.
- Save the
.gz
file to yourDownloads
directory.Login over the network to the Raspberry Pi as user pi, and create a directory for the Java download:
$ ssh pi@RaspberryIP mkdir /home/pi/java
Copy the Java download to the new directory on the Raspberry Pi:
$ scp ~/Downloads/*.gz pi@RaspberryIP:/home/pi/java
Unpack the Java download:
$ ssh pi@RaspberryIP
$ cd /home/pi/java
$ tar -zxvf *.gz
...
Launch Java:
$ ls ejre*
ejre1.7.0_04
$ cd ejre*
$ ./bin/java -version
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment for Embedded (build 1.7.0_04-ea-b20, headless)
Java Hotspot(TM) Embedded Client VM (build 23.0-b21, mixed mode)
Some details, such as version and build numbers, might have changed since this article was written.
Optionally, remove the download file:
$ rm /home/pi/java/*.gz