How to perform custom similarity

I'm new to Elasticsearch and would like to override the default similarity. I found this code and understand that the java files have to be compiled into a jar file. But beyond that, I don't know how to proceed. Can someone please give a step-by-step procedure that a newbie like me would be able to follow? Thanks, in advance

compile and jar the class file. then specify the jar file in the elasticsearch classpath for all the nodes including client node?