Xcode set run to run java but java said can't find java

I wan't to use Java in Xcode the class file is Main.class. So I set scheme -> run to a script like this:

#!/bin/sh
java -cp $(dirname $0) Main

But when I run it, java said :

Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main

How can I fix this problem?

And: It's really helpful to answer in Chinese if you know it.