[SPARK-4504][Examples] fix run-example failure if multiple example jars present

Fix run-examples script error during multiple jars.
Modified to support failing fast similar to assembly.jar

Author: Venkata Ramana G <ramana.gollamudi@huawei.com>
Same here. It would be great if we could avoid this pattern of capturing the output of `ls`, though it's not a big deal honestly since the old code did this as well.