Possible Duplicate:
Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”'
i got this error after i added a method called setConstraints in Generator.class.im free from error when i compiled. this is the error: Exception in thread "main" java.lang.NoSuchMethodError: rtg.Generator.setConstra ints(Ljava/util/ArrayList;)V at rtg.DefaultPrompt.main(DefaultPrompt.java:117)
this is the method of setCostraints() in Generator.java
private ArrayList<String> constraints_list = new ArrayList<String>();
private boolean constr = false;
public void setConstraints(ArrayList<String> c)
{
constraints_list = c;
constr = true;
}
this the class that is using Generator.class
public class DefaultPrompt
{
public static void main()
{
Generator gen = new Generator();
gen.setConstraints(constraints_list);
}
{
both classes r in the same package.before added setConstraints, no error.
anyone knows how/why its happen?
Sounds like the class was not re-compiled after you added the method. Sometimes this happens in some environments. Try deleting all the .class files in the directory and re-compiling again.
did u noticed the error clearly u can see the space in the method name
Exception in thread "main" java.lang.NoSuchMethodError: rtg.Generator.setConstra ints(Ljava/util/ArrayList;)V at rtg.DefaultPrompt.main(DefaultPrompt.java:117)
精彩评论