Posts

Showing posts from 2013

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 Google Map which is centred on

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

Dealing with Amazon Web Service Access Keys

Image
Amazon Web Services ( AWS ) access keys are required to make API calls for the range of AWS services. These keys can be troublesome, as the tendency is to hard code the values in your software ( which many internet examples do ) or to use configuration files which hold them in plain text. In many ways this is bad. The secret key once displayed to you ( as the user ) is never returned again, hence its importance can not be understated. However there is a way around this problem and its associated with AWS Identity Access Managemen t ( IAM ) roles and AWS EC2 Instance s. In the digram above an application hosted on an EC2 instance requires access to S3 Objects. If you use the AWS Java SDK you can create a S3 Client Object which has a constructor which receives the private and access keys. AmazonS3Client s3Client = new AmazonS3Client(AWSCredentials creds); The constructor for this client receives a AWSCredentials object which is built using the secret and access key.

Vaadin 7 - because I have to

I have been resisting Vaadin 7 for a long time. Trapped in version 6, at times I have created an illusion that version 7 didn't exist. "I will get to it, soon, soon", I would say to myself. But, its time. I have bought a book , downloaded the book code and cracked open the first example. My initial impressions, Vaadin 7 is different from version 6, not just a "little different", its different by a wide margin. This journey is going to be all up hill.

A View Manager in Vaadin

One of the problems I faced early on in developing a Vaadin Application was how to move from one screen to the next. I managed to find a example pattern which is based on a "View Manager". This object is responsible for maintaining the various screens within the application. At any point you can ask the "Manager" for a previous screen and you can display its contents. The example I found that uses this pattern is called the " Gas Diary ". The View Manager class itself contains a HaspMap and a Stack. The HashMap contains a string for the name of the view and a Layout. The Stack contains a Layout. In the Gas Diary Main Application the Login Screen is "switched" to via this process. setMainWindow(mainWindow); viewManager = new ViewManager(mainWindow); // Create the login screen viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen()); This method has worked for me

Open Search Server - A Discovery.

Search. The missing app in organisations. In my opinion poor search is the root of "knowledge management" issues. In fact, I think a poor search platform is to blame for huge duplication within organisations. In reality, no one can find anything in your average company. Open Search Server is an interesting open source solution in this space.

Google Drive API Example - What worked for me

Image
An interesting Java example exists for the Google Drive API on the Google Developers Site . It is located in the Quick Start menu. It is intended to provide developers with a simple way to start using the Google Drive API. While this is a welcome extension provided by Google, I ran into problems making this example work. The first problem I encountered was enabling the Drive API. The instructions indicated that you are required to "enable the Drive API". I did this, but it appears you also need to enable the Drive SDK as well. If you fail to enable both you receive an "access not configured" error. The 2nd problem that caused me a few hours of frustration was the inability to build the example using the suggested Maven configuration. After numerous attempts I was able to settle on this Maven configuration which appeared to work. <dependency>       <groupId>com.google.apis</groupId>       <artifactId>google-api-se

Mounting a windows folder from a Linux Host

I use VMWare Player to run Linux VM's on a Windows Host Machine. I use the Linux VM's as a development environment. To mount a windows folder in my Linux VM I use this command. sudo mount -t vmhgfs .host:/ /home/user/shares This gives me a folder ( shares ) in my Linux host which points to the windows folders I have made available from the Host operating system ( in my case Windows 7 ).

Oracle - FIX JAVA !!!!

I have been a loyal Java Developer since 1995.... Thousands of lines of Java have flowed from my fingers. At times, my fingers just seem to "know" what next statement to write. I don't have to think about it. But, my patience has run out. Another Java Zero Day exploit has hit the "fan". Oracle, its time. Its time, to use your billions to fix Java. The future of Java is at stake and the clock is ticking....

Vaadin ThreadLocal

I use the Vaadin Thread Local pattern in my Vaadin applications as a means to move the Application object around the various components and to implement a authentication process. The structure of an application which uses this pattern is as follows: public class Vaadin Application extends Application implements HttpServletRequestListener {      private static ThreadLocal <Vaadin Application > instance = new ThreadLocal <Vaadin Application >() public Vaadin Application () {         instance . set ( this );     } @Override     public void onRequestStart ( HttpServletRequest request , HttpServletResponse response ) {         instance . set ( this );     }     @Override     public void onRequestEnd ( HttpServletRequest request , HttpServletResponse response ) {         instance . remove ();     }     public static Vaadin Application getInstance () {         return instance . get ();     } }

Auto Starting and Stopping Tomcat on Linux

Most of the time I install Apache Tomcat as a Tar file on Linux. This works well when I just want to manually start and stop Tomcat from the command line. However if you have installed Tomcat on a Amazon EC2 instance, then you its a good idea to automatically start and stop Tomcat on server starts and re-starts. So, the following steps worked for on Ubuntu 12.04. Create a start up and shutdown script for Tomcat sudo nano /etc/init.d/tomcat In the file you should enter the following commands ( except for the changes for your environment ) # Tomcat auto-start # # description: Auto-starts tomcat # processname: tomcat # pidfile: /var/run/tomcat.pid export JAVA_HOME=<this is the folder where you have Java installed> case $1 in start)         sh <this is where tomcat is installed>/startup.sh         ;; stop)         sh <this is where tomcat is installed>/shutdown.sh         ;; restart)         sh <this is where tomcat is installed>/shutd

HTML 5 Test

HTML 5 promises a major change to web development. But, does your browser support HTML 5.? Test it out - here .

First fun for season

Image
Wet......