1. Install Real-time Java VM
There is a bunch of RT VMs that you can donwload and use but perhaps the one that is the easiest to install and to play with is Oracle's Java RTS. The current version is Java RTS 2.2. After filling the download form, you should be able to download it to your desktop. The name of the donwloaded file will be something like : java_rts-2_2-fcs-bin-b19-linux-i586-eval_academic.zip
- RT Linux - if you want to really run with real-time priorities. However, for starting and learning how to work with RT VMs, a regular linux should do - try eg. Ubuntu or Fedora OS.
untar downloaded distributable into /opt/jrts2.2 directory. Let's call it RTJAVA_HOME.
For more details, see SUN Java RTS Technical Documentation. Java RTS is distributed under restricted academic license that expires after 365 days but don't worry, you can just dowload a new distribution and re-install it.
1.2. Verify the Installation
You should see:
In case you are not running in a real-time environment or your linux does not have the rt-kernel extensions, you will also see the following warning:
You can safely ignore this one for testing RTSJ.
1.3. A missing libcap.so problem
However, a problem can occur when running the "./bin/java" on some systems:
This happened to me both on Ubuntu and Fedora OS. There is a detailed description of this problem here (as it appears, I was the first person to identify this issue).
Solution to the missing libcap.so.1 lib is to locate a libcap.so.2 and rename it as libcap.so.1
2. Runnig a Real-time HelloWorld program
Now we can finally run some real-time Java code. A classical real-time Java hello world example is below:
To compile the Real-Time HelloWorld class:
And, to run:
And we are done!
Further resources on RT Java:
- Concurrent and Real-time Java Programming book,
- try our CDx - Real-Time Java Benchmark,
- Oracle's RTSJ Introduction
- Embedded and Real-time Computing class taught by Prof. Vitek (check out the slides for selected topics)
Further blog-post on the same topic: