Run a java program from command line

Hello, I am extremely annoyed with my inability to run a java program from command line. I have tried using ant with no success. What is the easiest way to run a java program from command line? Here is what i have tried:

javac -cp . *java (within the directory of all of my .java files, seems to work)

javac -cp . NameOfClassWithMainMethod

then I get this error: Exeption in thread "main" java.lang.NoClassDefFoundError: Wrong name: dir/NameOfClassWithMainMethod

Followed by 10 lines of defineClass and LoadClass errors.

What am I doing wrong here. Is it me or does windows suck at running java from command line.

[651 byte] By [mateobusa] at [2007-10-3 8:09:48]
# 1
It's you. You're trying to use the compiler to both compile and run.The second time, it's just "java", as in "java -cp . NameOfClass".
paulcwa at 2007-7-15 3:14:06 > top of Java-index,Java Essentials,Java Programming...
# 2
No i was typing that correctly just a typo above thanks
mateobusa at 2007-7-15 3:14:06 > top of Java-index,Java Essentials,Java Programming...
# 3
Well then the problem is that the class was in a package, and you didn't place the class in a location expressing that package relative to the classpath.Or maybe something completely different is happening, but I can't tell because the information you're providing is inaccurate.
paulcwa at 2007-7-15 3:14:06 > top of Java-index,Java Essentials,Java Programming...