When we aren’t busy making Liberty awesome, we’re often looking at how we can get Liberty to do awesome things. Gabriel Knepper Mendes, a member of the WebSphere IT Services team, describes how he got Liberty running on a Mini X TV Box.
What is a Mini X TV Box?
A Mini X TV Box is a small device that transforms a standard LCD, plasma, or LED display into a smart TV. Often termed a “cloudstick”, due to a form factor similar to a pen drive, these devices run Android OS, provide connectivity through WiFi, and display using a HDMI interface. There are many variants of these devices available, in this case I used a version with 1GB RAM. I’d also expect it to run on the 512MB version, as the Liberty team have Liberty running on a phone with this spec.
The Mini X TV Box provides the basic hardware, but I also needed a few extra items. The device has a single USB port, so I used a USB hub to allow me to connect a keyboard and a mouse to the device. I also needed an internet connection, and I had to have WiFi as the device does not provide an Ethernet port. I used a 4GB Micro SD card to load the image on to, which was blank as the steps to load the image on wipe the card completely.
To get Liberty running, I needed to do the following:
- Install Linux.
- Download a JVM.
- Download Liberty.
- Start Liberty.
Installing Linux on a Mini X TV Box
The Mini X TV Box comes with Android 4.0 (Ice Cream Sandwich) on its internal 4GB flash memory, but as I needed a full Java SDK I had to find a way to get Linux running on it instead. To avoid changing the device, I decided to install Linux to the external SD card and boot directly to that. This means that if I want to get back to the Android OS all I need to do is turn off the device, eject the SD card and turn it back on again.
I chose Lubuntu because of the size, Ubuntu didn’t fit on my SD card. Lubuntu has 4 versions which are customized to different hardware. My Mini X has 1GB RAM and Iâ€™m using an LCD VGA monitor with a HDMI adapter instead of a TV. This led me to use the 1GB RAM and 720p version. This is available on the Miniand website.
To write the image to the SD card I used a Windows 7 laptop with an internal SD card reader, and used the instructions from the Miniand forums. Once the image was prepared I simply put the SD card in the Mini X TV Box and switched it on. I found that the front LED on the device remains red, like it does when in standby if running Android, however this didn’t seem to affect the operation of the device.
Installing a JVM on Linux
Once I had Linux running, I logged on as
Ubuntu System User, using the password
miniand, which is the default password for the image, and installed a JVM. I chose the OpenJDK 6 from the Ubuntu repositories, using the package installer. It was at this point I realised how handy having the Keyboard and mouse plugged in was! Of course it is also possible to install OpenJDK from the command line, and I could’ve run
apt-get install openjdk-6-jdk from the command line to achieve this.
To make sure the JVM was correctly installed, I ran the command
java -version from a command shell to check the JVM was installed correctly and on the path.
I downloaded the Liberty from WASdev directly inside the Mini X TV Box by going to the Downloads page. I used Chromium as it was already in the image. Once the self-extracting JAR file was downloaded, I moved it from
/home/miniand, and followed the installation instructions on the Download Liberty page.
After that I created the server by running the command
server create defaultServer from
/home/miniand/wlp/bin, dropped the
defaultApplication.ear file inside
/home/miniand/wlp/usr/servers/defaultServer/dropins, and started the server using the command
server run defaultServer from
/home/miniand/wlp/bin. I could then follow the instructions in the command shell and navigate to
http://localhost:9080/snoop to view output from the application.
Based on the small size and low cost of this piece of hardware it has a number of possible uses in many projects that need be portable, like in embedded projects for example. Maybe it’ll even end up in a hat one day…