PDA

View Full Version : No Such method error


grifan526
03-03-2009, 09:08 PM
I am new to Java so I am sure this is an easy one for some of you. I am working a project that reads information from a file and then sorts it. It compiled but when I ran it I got this error:
java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1

my main method is:


public void main(String[] args){

Vehicle[] List=new Vehicle[20];
Scanner ListInput=new Scanner(args[0]);
int i=0;
for(i=0;ListInput.hasNextLine();i++){
if(i==List.length){
Vehicle[] temp=new Vehicle[List.length*2];
for(int j=0;j<List.length;j++){
temp[j]=List[j];
}
List=temp;
}


There is more but it involves classes I wrote and I want to keep the code here short. If anyone can help me with this I would greatly appreciate it.

Fou-Lu
03-03-2009, 09:14 PM
public void main(String[] args) != public static void main(String[] args)
It will compile because you don't actually need an entry point, but when runtime comes along it chokes because it doesn't have a usable entry point.

I actually found a link awhile back that showed all the different possible signatures that Java main could have. I'll see if I can find it again... ah, sorry no. Thats ok, stick with public static void main(String[] args).

grifan526
03-04-2009, 12:01 AM
Thanks you, i got that part of my program cleared up.