I have a Java program Desktop/testfolder/xyz.jar on a remote machine. It has a configuration file on the same folder. When I SSH into the machine, I do:
Desktop/testfolder/xyz.jar
You could try separating the commands by a semicolon:
ssh user@remote "cd Desktop/testfolder ; java -cp xyz.jar Main"