Java compile - Eclipse
February 28, 2008 by muralis
Could not find the main class. Program will exit.”
Problem : I just installed the latest available Eclipse version (3.2 milestone 5) and couldn’t run my ANT builds anymore. The error I got in the alert box was “Could not find the main class. Program will exit”.
Solution : The problem was that the ANT_HOME variable was still pointing to the previous Eclipse folder and the solution was simply to change the path. This can be done through Window->Preferences->Ant->Runtime. Once there, click the “Ant home…” button in the “Classpath” tab and browse to the ANT plugin folder in your Eclipse installation. Now hit the OK button and try to run the build file again. Everything should work again.
Java main Method
Every Java program must have one main method. The main method is the first method, which the Java Virtual Machine executes. In other words, when you execute a class with the Java interpreter, the runtime system starts by calling the class’s main() method. The main() method then calls all the other methods required to run your application. The main method is the entry point in the Java program and java program can’t run without main method.
The signature of main() method looks like this:
public static void main(String args[])
The method signature for the main() method contains three modifiers:
public indicates that the main() method can be called by any object.
static indicates that the main() method is a class method.
void indicates that the main() method has no return value.