Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError error

 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have created a .class file from a .java file on my desktop (C:\Documents and Settings\ptalek\Desktop\MyFirstJava.java) & (C:\Documents and Settings\ptalek\Desktop\MyFirstJava.class).

Below is the code for MyFirstJava.



But I'm unable to run this program using the java command.

I'm using following commands in the command prompt:



I got the below error :



Please advise.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java -cp . MyFirstJava .

and dont use desktop , it troubles you after sometime.
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typical classpath problem indeed. Check the JavaRanch FAQ. This document and others will surely help you avoid many pitfalls. Then again, stepping into pitfalls means you have to get out of them and that learning process is good for you

Cheers,
Wim
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Seetharaman & Wim.

It's working now.
The doc I'm referring to doesn't show this classpath statement

Thank you so much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic