Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError

 
AaronMweu Munzaa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I compile this code:::
***********************************
import java.util.Date;
class NewDate extends Date{
public void display(){
System.out.println(toString());
}
}
class DateShow{
public static void main(String args[]){
NewDate today = new NewDate();
today.display();
}
}
****************************
its compiles ok but when I try to run it I get this error:
Exception thread in "main" java.lang.NoSuchMethodError: main
AND
What do I do in order to be able to compile my code from ms-dos prompt without having to specify the directories and all that?
Please help
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must execute with DateShow and NOT NewDate:
> java DateShow
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your file must also be called DateShow.java.
What do I do in order to be able to compile my code from ms-dos prompt without having to specify the directories and all that?

If you include "." (current directory) in your CLASSPATH environment variable, then you can compile DateShow.java from within the directory it resides. So, if DateShow.java is in d:\projects, you can do this: I think that's what you were asking.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic