简体   繁体   English

JavaFX应用程序类必须扩展javafx.application.Application

[英]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.

相关问题 JavaFX 应用程序类必须扩展 javafx.application.Application --> 即使存在 main 方法,也会出现此错误 - JavaFX application class must extend javafx.application.Application --> Getting this error eventhough main method is there 无法构造javafx.application.Application实例 - Unable to construct javafx.application.Application instance 将引用传递给javafx.application.Application - Passing reference to javafx.application.Application java.lang.ClassNotFoundException:javafx.application.Application - java.lang.ClassNotFoundException: javafx.application.Application 导入 javafx.application.Application; 无法在 Eclipse (Ubuntu 18.04.1) 中工作 - import javafx.application.Application; not working in Eclipse (Ubuntu 18.04.1) Java中没有javafx.application.Application包 - Don't have javafx.application.Application package in java 错误:package javafx.application 不存在导入 javafx.application.Application; - error: package javafx.application does not exist import javafx.application.Application; 运行JavaFX Maven插件后出现javafx.application.Application的NoClassFoundException(修复类路径) - NoClassFoundException for javafx.application.Application after run JavaFX Maven Plugin (fix-classpath) JavaFX 应用程序类不在 javafx.application 包中 - JavaFX Application class not in javafx.application package 缺少 JavaFX 应用程序类 - Missing JavaFX application class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM