How to call a function present in my java class on a button click?

I have added a button next to create issue button in my jira server and want to call a function present in my java class. Please suggest some method to call my function on clicking the button .

You can wrap this button in a <form> with it’s action attribute pointing to your webwork action class/Java servlet. But this form submission will cause a page refresh.

Other option (without causing page refresh) is to handle this button click using JavaScript and send an AJAX REST call.
In this case your Java class needs to be a REST API.

You can find implementation details in documentation/other community posts etc