Use this tag for questions related to Java based server side implementation of WebSocket.
Java SE has no standard API for WebSocket, there's a 3rd party library: Java-WebSocket.
Writing your own WebSocket Server
The org.java_websocket.server.WebSocketServer abstract class implements the server-side of the WebSocket Protocol. A WebSocket server by itself doesn't do anything except establish socket connections though HTTP. After that it's up to your subclass to add purpose.
Writing your own WebSocket Client
The org.java_websocket.server.WebSocketClient abstract class can connect to valid WebSocket servers. The constructor expects a valid ws:// URI to connect to. Important events onOpen, onClose, onMessage and onIOError get fired throughout the life of the WebSocketClient, and must be implemented in your subclass.
Java EE has a standard API for server side implementation of WebSocket: JSR356.