Update-4th Jan 2014 : OMXPlayer start and stop now working through Rest Interface
I've successfully managed to deploy a minimal Spring Boot application which contains only one controller to interface with the Pi's omxplayer on a Raspberry Pi device. Although I managed to deploy the Spring Boot application properly and the rest interface is working , interaction with the omxplayer is still work in progress :) !
Below you will find the steps to get started installing JAVA and your existing Spring Boot application on the PI.
Installing Java on the PI
All that is really required as a pre-requisite is that JAVA needs to be installed and this is achieved with the following command on the PI:
sudo apt-get update && sudo apt-get install oracle-java7-jdk
The command will update your Raspberry Pi OS in my case its
Raspbian and afterwards will install JAVA 7 embedded on your device its a 70+ MB download , so took less than 12 minutes in Mauritius .
Then once downloaded the install will unpack by itself here you need to have a little dose of patience , remember the Raspberry is not like your standard pc , give it some time :) .
Once everything has been installed go to your ssh client on Mack or Putty on Windows and execute the following command to check whether Java has been installed properly:
java - version
Running your Spring Boot Application
This section assumes that you already have a working Spring Boot application the one I've deployed merely exposes a Rest interface but does not have to persist anything in a database .
Note that there are lots of examples already available from the Spring.io GIT hub check the webui one here :
A simple getting started guide is also available here:
I've decided to use Jetty as the embedded servlet container as it is much lighter than Tomcat , so you will need to add the following within your maven POM file are adapt it to your gradle build if thats what your using.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>0.5.0.M6</version>
</parent>
<groupId>com.your.groupid</groupId>
<artifactId>your-artifactid</artifactId>
<packaging>jar</packaging>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Note that the jackson-databind is required for exposing your Rest interface.
Once you are satisfied with your spring boot application and have tested that it is working properly its time to deploy the app on your Raspberry .
Get hold of your favorite FTP program and transfer generated Jar file to your /home/pi directory for example.
Then all you need to do is to execute the jar file as follows:
java - jar your-jar-filename-xxx.jar
where your-jar-filename-xxx needs to be substituted with the name of your generated jar file.
My application as mentioned was just a couple of classes big but it did take around 82 seconds to be installed , however once installed it ran without any issues , so this is promising.
Ok that's it for now , I need to work a bit more on my Raspberry application such as I can finally provide a RESTful interface to the omxplayer , one thing for sure is that Spring Boot makes deploying a webserver on the raspberry device something as easy as executing a JAR file.