Mark,
You can create vars putting them in main.yml under vars.
Following your directory structure, it would be there :
myscripts/roles/the_role/vars/main.yml
See the directory layout section in the Best Practices page.
For instance :
class_path: "A.jar:B.jar:C.jar"
Then in your tasks :
- name: java | Do something with Bar Java class
action: command java -cp {{ classpath }} com.example.Bar myargs
- name: java | Do something with Foo Java class
action: command java -cp {{ classpath }} com.example.Foo myOtherargs
Good luck.