This is good, that is why you are able to get the code compile with out any issue with IDE. Can you also check the version of Java in command line as Campbell Ritchie suggested. Check if you are using 1.5 or above, else point your Java accordingly and test again.
I tested the code and was able to compile the same code in command line with out any error in my machine. Can you compile the code once again in command line with "javac" and see if you get the same error again, if so can you share a screen short or steps you follow to compile and run your code.
You are getting one more error "reached end of file while parsing"
Can you just see why that error is coming up and clean that error and try.
This error will come when you have some bracket closing issue with code.