Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
error "running" java programs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
azambuja
Apprentice
Apprentice


Joined: 12 Jul 2002
Posts: 257
Location: Porto Alegre, RS, Brazil

PostPosted: Sat Jan 04, 2003 2:16 am    Post subject: error "running" java programs Reply with quote

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
View user's profile Send private message
red_over_blue
Guru
Guru


Joined: 16 Dec 2002
Posts: 310

PostPosted: Sat Jan 04, 2003 2:25 am    Post subject: Reply with quote

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:

Code:
javac program.java


Which is perfectly fine. But then, some people try to run it by typing:

Code:
java program.java


When you should only do the following:

Code:
java program


I'm not sure if this is what is happening in your case, but sounds like it might be a possibility.
Back to top
View user's profile Send private message
zhenlin
Veteran
Veteran


Joined: 09 Nov 2002
Posts: 1361

PostPosted: Sat Jan 04, 2003 2:50 am    Post subject: Reply with quote

Make sure . is in CLASSPATH.

Also, if <class> is in <package>, execute it as <package>.<class> from the appropriate directory.
Back to top
View user's profile Send private message
azambuja
Apprentice
Apprentice


Joined: 12 Jul 2002
Posts: 257
Location: Porto Alegre, RS, Brazil

PostPosted: Sat Jan 04, 2003 4:52 pm    Post subject: Reply with quote

red_over_blue : thats definately not the problem, im not that dumb :D
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
View user's profile Send private message
Valen
Apprentice
Apprentice


Joined: 18 Aug 2002
Posts: 197
Location: Toronto, Ontario, Canada

PostPosted: Sat Jan 04, 2003 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum