You can use httpserver inside your Java application to share information. It's pretty simple - just few lines of code. Of course your computer should be available for other computers with web browser.
That's one way communication client to server. If you need 2-way communication you still need to obey http rules (not because of Java but because you use browser as the client).
Here what I do. In JavaScript open connection, It could be anything - AJAX, image, JavaScript source for new JavaScript dynamic object (that's what I do). On the server side open but don't close connection - wait till you have something to send. When you have it - send it. Browser will have it at this exact moment. Plain and simple. However, there is necessary trick: if server waits to long (2 minutes) browser closes the connection. In this case your JavaScript should be ready and make the same request again. And os it repeats. On server side your connection will be closed but new one will be opened and it will wait when you are ready. One more trick - when you do new request from browser side - don;t forget about cache. To not have the same answer from cache add something unique to the request. For example current time as parameter.