JavaFX应用程序类必须扩展javafx.application.Application [英] JavaFX application class must extend javafx.application.Application
问题描述
JavaFX应用程序类必须扩展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();
}
}
以下是错误:
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.
推荐答案
我最近遇到了类似的问题。
之所以发生这种情况,是因为您的目录
中可能包含与内置Java类名称相同的任何类文件。例如在我的情况下,当我将它作为参数传递给我的主函数时,我使用了String类,因为 public static void main(String args [])
我也是在同一目录中拥有自己定义的String类。
所以我重命名了我的字符串,对我有用。
您可以重命名/删除您定义的类名,也可以更改目录。
使用Java的内置类名来定义自己的类名不是一个好习惯。它可能会导致很多问题和混乱。
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.
这篇关于JavaFX应用程序类必须扩展javafx.application.Application的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!