[英]JavaFX application class must extend javafx.application.Application
JavaFX application class must extend javafx.application.Application JavaFX应用程序类必须扩展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. 请在上述程序中为我提供正确的代码。
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. 发生这种情况是因为您的目录中可能有任何名称与内置Java类名称相同的类文件。 For eg 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. 例如,在我的情况下,当我将String类作为参数传递给我的主函数(作为public static void main(String args[])
,我正在使用String类,并且在同一目录中也有自己定义的String类。
So I renamed my String which worked for me. 所以我重命名了对我有用的String。
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. 使用Java的内置类名定义自己的类名不是一个好习惯,这可能会导致很多问题和混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.