Typically, applications make server-side Java methods available to the client side by exposing them as end-points in a REST web service. Although this is a perfectly valid approach, this example shows an alternative way to call Java methods on the server without having to implement web services. This is possible thanks to Vaadin Flow, a framework that incorporates a set of Java classes that, not only allows you to build web UIs in plain Java, but also includes an automated communication mechanism that makes calling Java methods from JavaScript straightforward.
Read the full tutorial at https://vaadin.com/tutorials/calling-java-from-javascript
Or watch the video at https://www.youtube.com/watch?v=3l0Ed8x2nCg