NoClassDefFoundError

E

Eli Luong

I was wondering what the reason is behind this. I recently installed
the Java 5.0 SDK. Compiling *.java files seems to work fine, but
whenever I try to run something, it gives me that NoClassDefFoundError.
I've seen a solution is to run it as java -classpath . ClassName, but
that's some strange workaround I don't like. Why is this happening? Do
I have to install the SDK in a directory that contains no spaces? By
default it ended up in Program Files\Java.

Thanks,
- Eli
 
K

Knute Johnson

Eli said:
I was wondering what the reason is behind this. I recently installed
the Java 5.0 SDK. Compiling *.java files seems to work fine, but
whenever I try to run something, it gives me that NoClassDefFoundError.
I've seen a solution is to run it as java -classpath . ClassName, but
that's some strange workaround I don't like. Why is this happening? Do
I have to install the SDK in a directory that contains no spaces? By
default it ended up in Program Files\Java.

Thanks,
- Eli

You shouldn't need a classpath to run a class in the current directory
if it has no package. Check to make sure that you don't have a
classpath specified in the environment. If you do, it could be that it
doesn't have . in it like it should.
 
A

aywang31

I got that error too when I re-installed a newer SDK version. I
believe that you should check your system's environment variables. On
Windows XP, go to My Computer, View System Information. Then go to the
advanced tab and click on Environment Variables. Under System
Variables, make sure that C:\Program Files\Java\bin (or wherever your
bin folder is) is in that variable's value. I'm pretty sure the error
is because your new SDK is in a different directory from your old one.
 
E

Eli Luong

Thank you to both who replied. I checked out the environment variables.
I'm not sure what I'm looking at. There is a variable called CLASSPATH
: C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip. It's pointing
to the old java runtime environment. I'm wondering what I should change
that to, because it's pointing to QTJava.zip.

In addition, another variable called QTJava : C:\Program
Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip is displayed, and I'm not
sure what to do with that.

What I did was just install the SDK (the compiler and the private JRE)
and not the public JRE, so that means I"m using the old JRE. Should I
install the new JRE and uninstall the old JRE?

Thank you,
- Eli
 
K

Knute Johnson

Eli said:
Thank you to both who replied. I checked out the environment variables.
I'm not sure what I'm looking at. There is a variable called CLASSPATH
: C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip. It's pointing
to the old java runtime environment. I'm wondering what I should change
that to, because it's pointing to QTJava.zip.

In addition, another variable called QTJava : C:\Program
Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip is displayed, and I'm not
sure what to do with that.

What I did was just install the SDK (the compiler and the private JRE)
and not the public JRE, so that means I"m using the old JRE. Should I
install the new JRE and uninstall the old JRE?

Thank you,
- Eli

Eli:

Probably the simplest thing to do now would be to unistall both the JDK
and JRE, delete the old folders and reinstall the JDK.
 
E

Eli Luong

Thanks. I had to do that and then set CLASSPATH to a "." and that
finally made it work. Whew.
 
O

Oliver Wong

Knute Johnson said:
Eli:

Probably the simplest thing to do now would be to unistall both the JDK
and JRE, delete the old folders and reinstall the JDK.

Sounds like Eli has some extensions related to QuickTime installed in
his/her JRE's extension folder. Perhaps it was bundled in with another Java
app (s)he had downloaded and installed earlier? If the applications suddenly
stop working, you might want to redownload the QTJava.zip, put it in your
new JRE's extension folder, and reconfigure your classpath and QTJava
environment variable to point to the new location:

http://developer.apple.com/quicktime/qtjava/

- Oliver
 
E

Eli Luong

Thanks, I'll keep that in mind if something strange happens. So far
nothing seems to be broken, so that's a good sign.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top