'Error: Main method not found in class, please define the main method as:public static void main(String[] args)
As my question is old but am new eclipse am not able to solve the error. can someone help in solving this.
public class Anita {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.hdfc.com/");
WebElement Housing = driver.findElement(By.linkText("Housing Loans"));
Actions myActions = new Actions(driver);
myActions.moveToElement(Housing);
}
}
When I execute above code, I got this error.
Main method not found in class, please define the main method as:public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
and why I need to extend javafx appilcation?
Thanks in advance.
Solution 1:[1]
You might be trying to execute on another class.
Open the class Anita in eclipse editor.
Right click on the class in editor > Run As > Java Application
If the main method is not found you will not be able to see the Java Application option.
Solution 2:[2]
Just save your work (Ctrl + s) then run again. Trust me, it all works! Thank me later :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sighil |
| Solution 2 | Justin Herrera |

