• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NoClassDefFoundError

 
Jeff Bergan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to use Dos to run programs. I can compile fine but when I try to run programs I keep getting a Exception found in thread "Main" java.lang.NoClassDefFoundError: <name of program>
 
Jyotsna Clarkin
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would imagine this is a problem with your CLASSPATH settings.
Please check that the directory containing your complied file is included in your classpath.

for example if you have
a file called Test.java
compiled to genetrate Test.class
in directory called c:\javaprojects
Then your classpath must include c:\javaprojects
This is just an example- your own files & directories can have any names you choose.
Also remember that the java names are case-sensitive.
Check that your source file has a main method.
regards,
Jyotsna
 
rajesh purohit
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check ur classpath it must include ur directory name where from u r running ur application (java program)
best of luck
Rajesh
 
Susan Delph
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the following to specify 'THIS' directory:
java -classpath . File
Replace File with the name of your program.
P.S. You said it compiled OK, but if you ever need to, you can also compile specifying 'THIS' directory:
javac -classpath . File.java

Susan
 
Jeff Bergan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, using -classpath worked like a charm
jeff
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic