【问题标题】:Need Help Creating runnable Jar file for a Java FX Application需要帮助为 Java FX 应用程序创建可运行的 Jar 文件
【发布时间】:2017-03-20 18:31:46
【问题描述】:

我在尝试为使用 Eclipse Neon 和 Java 1.8 构建的 Java FX 应用程序创建可运行的 Jar 文件时遇到问题。当我尝试通过 Runnable Jar File Specification 对话框从 Eclipse 生成 Runnable Jar 时,我收到错误消息:“Could not find main method from given launch configuration。”

我在“启动配置”下拉菜单中指定主类。

感谢任何帮助!

谢谢!

【问题讨论】:

    标签: eclipse javafx


    【解决方案1】:

    您的项目根目录中应该有一个build.fxbuild 文件。右键单击该单击Build Export FX Application。您的 jar 将位于 <project>/build/dist

    【讨论】:

    • 嗨 Zeron01alpha,没有。我做了一个 linux 查找,我的项目没有那个文件。也许我没有正确创建我的 JavaFX 项目?
    • @user1104028 你是如何创建它的?我使用 Java FX 项目模板,File -> New -> Other... -> JavaFX -> JavaFX Project
    【解决方案2】:

    您可以通过添加在应用程序中定义的 public void main() 来解决此问题,因此:

    public class myApplication extends Application
    {
      public static void main(String[] args)
      {
        launch(args);
      }
    
      public void start( Stage stage ) throws Exception
      {
        ...
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-23
      • 2011-08-09
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多