Created a file Server.java which will run on a System and will wait for connection request(in an infinite loop). This file in Server.java has main funciton defined with correct signature but still I am getting following error.
Error: Main method not found in class Server, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
class Server {
final static int TRACKER_PORT = 5000;
public static void main(String args[]) {
try (ServerSocket s = new ServerSocket(TRACKER_PORT)) {
System.out.println("The tracker server is running on port " + TRACKER_PORT);
Tracker t = new Tracker();
while(true) {
Socket cl = s.accept();
new Handler(cl,t);
}
}
catch(Exception e) {
System.out.println("Unable to open socket");
}
}
Dear All, Thank you for your time and efforts. Above problems has been solved. It occured because a Server.class also existed at one of the path I set as CLASSPATH. so compiler was looking for main function in that file and that file doesn't had any main file. I re-run the code after removing that CLASSPATH and now code is running fine.