You can see how to do selections in this example
Click on the "View source" button to get the source code.
To make the selection programmatically you can do:
SelectFeature programmaticallySelectFeature = new SelectFeature(layer);
programmaticallySelectFeature.select(feature);