Hima
Hima

Reputation: 29

JavaFX application class must extend javafx.application.Application

JavaFX application class must extend javafx.application.Application

package automationFramework

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SecondTestCase 
{
     WebDriver driver;
          public void invokeBrowser()
     {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Venkat\\Desktop\\Hima2017\\Selenium\\chromedriver_win32_latest\\chromedriver.exe");
         driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
         driver.get("http://amazon.com");
     }
     public static void main(String args[])
     {
         System.out.println("This is second program");
          SecondTestCase myobj=new SecondTestCase();
        myobj.invokeBrowser();
     }
}

Following is error:

Error: Main method not found in class automationFramework.SecondTestCase, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

Please help me with the correct code in the above program.

Upvotes: 2

Views: 8978

Answers (1)

Praveen Ojha
Praveen Ojha

Reputation: 1211

I suffered from a similar problem recently. It occurred because you might be having any class file in your directory which have same name as an inbuilt Java Class name. For e.g in my case,I was using String class when I passed it as a parameter to my main function as public static void main(String args[]) and I was also having my own defined String class in the same directory.
So I renamed my String which worked for me.
You can either rename/delete your defined class name or you can change the directory.

Using Java's inbuilt class names to define your own class name is not a good practice.It can cause a lot of problems and confusion.

Upvotes: 3

Related Questions