| Author |
NoClassDefFoundError
|
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Have written following code for Server Socket:
It's giving an error that
Exception in Thread Main: NoClassDefFoundError
* I used public keyword before classname
* Classpath of c:\program files\java\jdk1.6.\bin (Classpath) already given and Java command is working
I have placed CLIENT program in same folder i.e C:\Java\
i am running command like this
Exception in Thread Main: NoClassDefFoundError
code isb elow
c:\java\ JAVAC Server.java
c:\java\ Java Server
and i am getting
Kindly tell what problem is? why it is not getting class defination?
waiting for reply
|
Regards
Azrael Noor
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
Azrael Noor wrote:
* Classpath of c:\program files\java\jdk1.6.\bin (Classpath) already given and Java command is working
The CLASSPATH tells Java where to find classes, not where to find Java. You could simply pass the current directory in on the command line:
HowToSetTheClasspath
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Ya it works,
but sir i am in that directory, in which i was working, i mean in which i have class files
then also it does not run. Why is it so?
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
I'm sorry, but it sounds like you just said "it works. it doesn't work".
You need to TellTheDetails.
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
* In first line, i am saying ya yours code is working and thanks for that
i.e c:\myClassFiles\> java -cp . Server
* In other lines i asked a question why it is not working if i am in same folder where my class files are located and i run Java command?
like c:\myClassFiles\> java Server
_______________________
just want to share, Sir you got to me remember a famous Poetry style of Asian Countries like Pak, india, which is called "Snake Style"(Bhujang Chant). For your general knowledge, in snake poetry style in one line or one stanza person convey two messages, sometime says one thing and sometime says other thing(but both opposite, like negative positive) i.e movement like snake. it's difficult for person to understand the facts of such poetry, if he does not have knowledge of concept. Same happened here...lol
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
Azrael Noor wrote:
* In other lines i asked a question why it is not working if i am in same folder where my class files are located and i run Java command?
like c:\myClassFiles\> java Server
Simple. That directory is not in the classpath. Do you have a CLASSPATH environment variable? The JVM will use it if if you do not specify a classpath on the command line. It will not just look in the working directory.
Azrael Noor wrote:
just want to share, Sir you got to me remember a famous Poetry style of Asian Countries like Pak, india, which is called "Snake Style"(Bhujang Chant). For your general knowledge, in snake poetry style in one line or one stanza person convey two messages, sometime says one thing and sometime says other thing(but both opposite, like negative positive) i.e movement like snake. it's difficult for person to understand the facts of such poetry, if he does not have knowledge of concept. Same happened here...lol
I have Bachelor's degree is in Literature, so this is interesting to me. English has many similar structures, from limericks to sonnets, that the poet can use to play with a reader's expectations.
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Simple. That directory is not in the classpath. Do you have a CLASSPATH environment variable? The JVM will use it if if you do not specify a classpath on the command line. It will not just look in the working directory.
Amazing, I never gave CLASSPATh before but i was able to run program when i remain in PRESENT WORKING DIRECTORY and my .JAVA and .Class files residing in same directory. This is first time i am not able to run any program without setting classpath. Howz this possible? May be it's thaumaturgy...lol
Thanks for answering and ya thanks for telling about two more poetry style will study about them in par time.
|
 |
 |
|
|
subject: NoClassDefFoundError
|
|
|