I used the following command to run the spark java example of wordcount:-
time spark-submit --deploy-mode cluster --master spark://192.168.0.7:6066 --class o
You need to enter the hostname in your /etc/hosts file. Something like:
/etc/hosts
127.0.0.1 localhost "hostname"