Home arrow static arrow Java Programming [Archive] - java.lang.NoSuchMethodError: main
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - java.lang.NoSuchMethodError: main
This topic has 2 replies on 1 page.

Posts:266
Registered: 2/27/04
java.lang.NoSuchMethodError: main  
Jul 12, 2004 8:11 AM



 
I have a small program that will not execute.
It complains about a missing main method, but the main method is there.

Here is the code.
It compiles fine but will not execute.

import java.util.*;
import java.util.Date;
import java.text.*;
import java.text.SimpleDateFormat;
import java.sql.*;

public class testDate{

public static void main(String[] args) {

String sql = null;
Date REPORTTRANSDATE = new Date();
String REPORTTABLE = "billercenter";
String REPORTBILLERID = "777";

sql = "SELECT " + REPORTTRANSDATE + " FROM " +
REPORTTABLE + " WHERE " + REPORTBILLERID +
"=?" + " AND " + "TO_DATE(" + REPORTTRANSDATE + ")" +
">=?" + " AND " + "TO_DATE(" + REPORTTRANSDATE + ")" +
"<=?";

System.out.println("SQL is: " + sql);

}
}

 

Posts:4,906
Registered: 23/07/02
Re: java.lang.NoSuchMethodError: main  
Jul 13, 2004 8:00 AM (reply 1 of 2)



 
I compiled and executed it without any problems. Can you copy-and-paste a terminal session which shows you compiling and attempting to execute it?
 

Posts:1,695
Registered: 1/13/04
Re: java.lang.NoSuchMethodError: main  
Jul 13, 2004 8:14 AM (reply 2 of 2)



 
I have a small program that will not execute.
It complains about a missing main method, but the main method is there.

That can happen if the same class (without main) exists in the CLASSPATH when you launch it.
Check the CLASSPATH, and/or scan your folders for a testDate.class file...
 
This topic has 2 replies on 1 page.