View previous topic :: View next topic |
Author |
Message |
azambuja Apprentice
Joined: 12 Jul 2002 Posts: 257 Location: Porto Alegre, RS, Brazil
|
Posted: Sat Jan 04, 2003 2:16 am Post subject: error "running" java programs |
|
|
hello,
ive got two java sdks emerged, blackdown and sun...
with any of them when i try to compile a .java class(which i know it has correct code) they compile fine, but when i run them (everyone of them) i get this error:
Code: | Exception in thread "main" java.lang.NoClassDefFoundError: |
i guess theres something to configure, or something like this...
thanx/cheers _________________ "Slip inside the eye of your mind, don't you know you might find, a better place to play" |
|
Back to top |
|
|
red_over_blue Guru
Joined: 16 Dec 2002 Posts: 310
|
Posted: Sat Jan 04, 2003 2:25 am Post subject: |
|
|
Can you post the commands you are using?
A common mistake is the following... suppose you have a java program called program.java
You compile it by issuing:
Which is perfectly fine. But then, some people try to run it by typing:
When you should only do the following:
I'm not sure if this is what is happening in your case, but sounds like it might be a possibility. |
|
Back to top |
|
|
zhenlin Veteran
Joined: 09 Nov 2002 Posts: 1361
|
Posted: Sat Jan 04, 2003 2:50 am Post subject: |
|
|
Make sure . is in CLASSPATH.
Also, if <class> is in <package>, execute it as <package>.<class> from the appropriate directory. |
|
Back to top |
|
|
azambuja Apprentice
Joined: 12 Jul 2002 Posts: 257 Location: Porto Alegre, RS, Brazil
|
Posted: Sat Jan 04, 2003 4:52 pm Post subject: |
|
|
red_over_blue : thats definately not the problem, im not that dumb
zhenlin : how do i add . to the classpath (im 90% sure that this is the problem)...
thanks for the help guys!
cheers _________________ "Slip inside the eye of your mind, don't you know you might find, a better place to play" |
|
Back to top |
|
|
Valen Apprentice
Joined: 18 Aug 2002 Posts: 197 Location: Toronto, Ontario, Canada
|
Posted: Sat Jan 04, 2003 10:55 pm Post subject: |
|
|
in /etc/profile.env you will see a setting for the CLASSPATH variable just change if from something like:
Code: | export CLASSPATH='/opt/sun-jdk-1.4.1.01/jre/lib/rt.jar' |
and add a ':.' like:
Code: | export CLASSPATH='/opt/sun-jdk-1.4.1.01/jre/lib/rt.jar:.' |
you will need to 'source /etc/profile' afterwards. You can also use the 'java-config' tool if you want (it does the same thing if you choose set-system-vm AFAIK).
EDIT: I just reread your original message, you may want to use java-config if you have different users using different JVMs. If you don't then I believe either solution will still work correctly. |
|
Back to top |
|
|
|