The implementation of all these examples and code snippets can be found in my GitHub project – this is an Eclipse based project, so it should be easy to import and run as it is.