1) Create your endpoint class. First, select "New"->"Web"->"WebSocket Endpoint":
Figure 1. Select WebSocket Endpoint
2) Next, name your endpoint accordingly, provide a package into which the endpoint will be created, and also provide a WebSocket URI. This is the URI that the client will connect to in order to send a message.
Figure 2. WebSocket Endpoint Generation
3) The NetBeans IDE will generate the initial WebSocket endpoint code. All that is left to do is implementation of the onMessage() method to suit your application.
I will show you how to easily generate a client to communicate with a WebSocket endpoint using NetBeans in a future Java EE tip!