Hello @kartik,
Normally this error occurs when you invoke java by supplying the wrong arguments/options. In this case it should be the version option.
java -version
So to double check you can always do java -help, and see if the option exists. In this case, there is no option such as v.
Hope this is helpful!!