Hmm I was once stumped by the same type of error for days.
What eventually turned out to be the problem was that I was running the WRONG "java" binary!
Yep, I know it sounds stupid / non-sensical, but I had two "java" binaries - one was the -real- SUN Microsystems java binary (it was in /usr/local/bin if I remember right) and the -other- was a "java" binary (I can't even remember where I got it - I think it was some package called Kaffe or something, or was installed by my distro automatically - Fedora Core 6) which was in /usr/bin...
I'm sure you see what I'm getting at - in my PATH, /usr/bin was listed BEFORE /usr/local/bin. This caused that, each time I called "java" in a shell window, the "incorrect" java was called. Same as you, I could compile everything fine (my system has only ONE javac binary...) but NOTHING wanted to work when I tried to run the compiled .jar
Took me hours to find this out. Eventually I solved this by searching my entire harddisk for ANY file called "java" - like this, when logged in as root:
That was where I spotted that I had TWO java binaries, in two seperate bin directories.
What I'm getting at is check your system that you have only ONE "java" binary - if you, like me, maybe have two... especially since, after the fact, you downloaded and installed your "own" instance of the Java SDK. If you DO have two, run the correct one by going
or whatever is the ACTUAL SUN Java SDK JVM binary for your system.
This is how I solved my issue with compiling fine, but absolutely refusing to run. Turns out the "other java" I had was completely deperecated and incompatible with what I was trying to do...