Posts

Google Guava HashBasedTable Example

Image
A simple example showing how to establish a Google Guava Hash Based Table. Notes A class called Board represents a Sudoku Board Create a Hash Based Table which contains a Cell Class Create the Hash Based Table in the constructor Load the board using a int array Print a simple representation of the board Cell class below shows a simple way to represent a cell on a Sudoku Board

Jersey Rest Basics

Image
I use the Jersey Rest API  and I always deploy to Tomcat. There are some basic things you need to do to make this work. There are few examples around the internet which are very good, but they seem to be focused on some very old versions of the framework. Number 1, make sure your web xml contains this configuration. Number 2, I use Maven , so this is my Pom File, this example includes the dependency for using JSON processing. Number 3, write some code. That's for another blog entry.

Web Cam and Vaadin

A very interesting Web Cam Add On is available from the Vaadin Add On site . Here is a simple recipe for making it work. Create a split panel and add the Web Cam to the left hand side of the panel. splitPanel = new HorizontalSplitPanel(); splitPanel.setSizeFull(); VerticalLayout detailsLayout = new VerticalLayout(); detailsLayout.setSpacing(true); detailsLayout.setSizeFull(); // Create the webcam and assign a receiver. final Webcam webcam = new Webcam(); webcam.setWidth("600px"); detailsLayout.addComponent(webcam); detailsLayout.setComponentAlignment(webcam, Alignment.TOP_LEFT); Create a receiver which creates a temporary file with a jpeg extension. webcam.setReceiver(new Upload.Receiver() { @Override public OutputStream receiveUpload(String filename, String mimeType) { try { targetFile = File.createTemp...

Java and KML Files

What is a KML file.? A Keyhole Markup Language File (KML) is a markup language to describe geographic data. How does it relate to Java.? An API exists ( which appears quite old ) which can process KML files. Either producing them or turning the KML files into Java objects. ( Marshalling or Unmarshalling ) Problem ? I recently downloaded some geographic data from a public dataset which was expressed as a KML file. Its my intention to use that data in a sample application. However I had a huge problem getting the API to un-marshall the data. It had a major problem with the namespace in the dataset. This namespace causes the API major problems. <kml xmlns="http://earth.google.com/kml/2.1"> After numerous hours I found this worked. ( so I replaced the above with the below ) <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom=...

Vaadin and Google Maps

Vaadin and a Google Map Widget One of my major irritations with Vaadin has been its lack of support for Google Maps as a standard widget. The reality is that many commercial applications require some form of mapping feature and the lack of support for a standard Google Map widget has been a major problem. However this has changed with Version 7.x of Vaadin, a new Google Map Addon has appeared and it fills a very important gap in the Vaadin feature set. How to Use It. If you use Maven in your development process then using the Addon in your Vaadin project is very easy. Just place this dependency in your POM file and make sure you have the correct repository established for the Vaadin Add On's. <dependency>    <groupId>com.vaadin.tapio</groupId>    <artifactId>googlemaps</artifactId>    <version>0.6.2</version> </dependency> Here is some simple code to get you started. It creates a Googl...

No Machine stopped after launching EC2 instance into new VPC - solved

The Error If you get this error from your No Machine Client Desktop NX> 500 Authentication failed NX> 500 Remote host identification has changed NX> 500 Offending key in /usr/NX/home/nx/.ssh/known_hosts NX> 999 Bye. NX> 280 Exiting on signal: 15 Solution I solved this by doing: Find file usr/NX/home/nx/.ssh/known_hosts which includes old keys used by your ssh daemon. Remove your old key(s) by commenting out the lines. Create new connection into host using No Machine Wizard. Thanks to this post

AWS Samples Behind a Corporate Firewall

Image
The AWS Java SDK includes some interesting examples of how to use the API for a range of different use cases ( S3, SQS, SNS etc ) These work well if they are installed on a EC2 instance. However, what if you are behind a Corporate Firewall and you want the example to access the AWS services on the internet.? The Amazon S3 Client Object contains a constructor which receives a Client Configuration Object. AmazonS3Client s3Client = new AmazonS3Client(AWSCredentials creds, ClientConfiguration config) The Client Configuration object has methods to establish a proxy configuration so that the client can connect into the internet via the proxy. ClientConfiguration config = new ClientConfiguration(); config.setProxyHost("ProxyHostName"); config.setProxyUsername("ProxyUserName"); config.setProxyPassword("ProxyPassword"); If you add this type of code into a AWS Sample then you should be able to punch your way through the Corporate Fir...