Java - Main class not found

From Global Programming Syntax

Jump to: navigation, search

Below is an example script that will have this bug with some IDE's:

public class filename {
public void main(String[] args) {
// TODO code application logic here
}
}

A very basic bug which can be easily be solved. To solve the error in the above script, the main method/function must be static. So below is how the main method/function should always be:

public class filename {
public static void main(String[] args) {
// TODO code application logic here
}
}

The reason. Your IDE cannot detect the main class since it is not global. And if the main class is not global it can not be globally detected.

Personal tools
languages
page stats
Toolbox