We try to write first Midlet and run it at Raspberry Pi device remotely. You need Raspberry Pi prepared. I’m using recommended OS for Raspberry: Rasbian. It’s debian based linux distribution prepared for this machine. If you work often with the same Pi you should set up static IP. It’s recommended way, you no need find current IP every reboot. You can do this in two ways: in the router, to bind IP with Pi Network Card’s MAC number, or at the Pi network config to retrieve static IP. The article doesn’t cover instalation and using ssh also. If all is prepared we can start.
Version 8 of the Java ME Embedded contains a different architecture than previous versions. With version 8, you have the option to run Developer agent on the desktop side under Windows. Commands that are sent to the board from Windows are no longer sent directly across the network. Instead, they are sent to the Developer agent, which transmits all comunication to and from
Java ME Embedded executable on the Raspberry Pi board.
Raspberry Pi is the one choosen platform that Java ME Embedded is prepared for. Go to the download site where you can download Java for this board.
You can unpack this on local computer, you’ll need it later.
Further put the archive on the Raspberry Pi board (by scp or ftp) and unpack it where you want. Archive has four directories:
/appdb contains internal Java libraries,
/bin contains executables and the
/legal contains important legal documentation,
/lib is needed only on the Windows, and contains the files needed to execute the Developer Agent on the desktop side.
I have unpacked it in the
/opt/javame directory. Don’t forget to add execution rights files under
chmod -R 777 appdb bin
Using Java Runtime on the Raspberry Pi
You can to this in few ways:
– You can execute commands directly at the rasbian shell,
– You can use Netbeans 8,
– You can use Developer Agent, started manually, and run commands using this tool.
/bin directory contains a set of sctript needed to run Java ME Embedded applications. What we can find:
installMidlet.sh– script for installing new midlets,
listMidlets.sh– show us list all installed IMlet suites and their statuses. If name of suite is used as parameter, its show the detail of this single suit.
removeMidlet.sh– You know, what the script is for. It’ for uninstalling midlets.
runSuite.shis for executing installed, specified by argument Suite\Imlet (or the default if none is specified). All logging information appears in the stdout. This command should be prepend with
sudoto ensure script has access to peripherals on the board.
The last one script I want to describe is
usertest.sh. This script is for running Raspberry Pi in the server mode.
In this mode you are able to run all above commands from remote machine. To be ensure the script obtain superuser privileges to access all the peripherals on the board, You have to run this script with
After this you can connect to AMS from remote machine.
Connecting to AMS from Windows.
Go to the directory when Java ME Embedded for Raspberry is unpacked. You can delete
bin the directories aren’t needed in Windows. Go to the
/lib and run command:
java -jar proxy.jar -socket IP_OF_YOUR_RASPBERRY
In the mode Application Management System must be already running.
If you want you can run proxy.jar in the Client mode, but check the documentation how to do this. Check the commands You can use within this connection at documentation too.
Using Developer agent
When you use Netbeans for developing Midlets you have also installed
Java ME Embedded Emulator 8.0 tool. When you start this application you’ll get access to three default emulators to test your midlet against them. But you can add you raspberry to the list. Use tool that is loaded into system tray: Device Manager. Click Add button, set the IP of your raspberry Pi board and finish with OK button. You’ll see manager will connect to the board. From this time, Your real board (not emulator) can be used directly from Netbeans as a device you want to run your IMlet.
Have a fun!