PDA

View Full Version : [SOLVED] Sudden new Java error "NoClassDefFoundError: java.util.Scanner"



Andante
October 11th, 2009, 05:20 AM
Hi everyone,

Just now when trying to run one of my programs that ran fine several days ago, and still works fine on other computers, I get this error message:

Exception in thread "main" java.lang.NoClassDefFoundError: java.util.Scanner

I'm not really sure what the problem is. The only thing I can think I've done since it last worked was install Eclipse, which I've removed to no luck.

for java -version I have
java version "1.5.0"
gij (GNU libgcj) version 4.3.3

(I know I installed version 6 update 16, and the java site still tells me I have it -- is this the same thing? I can't tell)

for javac -version I have
Eclipse Java Compiler 0.894_R34x, 3.4.2 release, Copyright IBM Corp 2000, 2008. All rights reserved.

which is kind of worrying since I don't even have that anymore. Regardless, without recompiling the program it still didn't work so I don't think this is the issue, though I fear it may cause some later on.

Any ideas?

Thanks!

shadylookin
October 11th, 2009, 07:46 AM
gcj is crap get the sun version of java. In the repos its something like sun-javajdk

then do this if you're using the eclipse ide

go into eclipse.
click window in the toolbar
under window click preferences
open up the java tag
click on compiler
make sure your compiler compliance level is 1.6

next click on Installed JREs
you should have something like java-6-sun-1.6.0.10 with a location of
/usr/lib/jvm/java-6-sun-1.6.0.10

Andante
October 11th, 2009, 07:10 PM
Thanks so much! I was able to Google how to change to the Sun version in the terminal as well so everything is working perfectly.

shadylookin
October 11th, 2009, 09:10 PM
No problem, it's a pretty common issue. I really wish they'd sticky the solution or even better dump gcj and replace it with openjdk as the default version of java.