• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

NoClassDefFoundError

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry, but it sounds like you just said "it works. it doesn't work".
You need to TellTheDetails.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
* 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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic