java - FX :deploy application not working but the Java jar is working - Gluon Project

标签 java ant gluon-mobile

我已经有了我的 gluon 项目,当从 Netbeans IDE 创建的 jar 运行(通过命令行并双击)以及使用 ide run 任务时,它可以工作。但我也尝试部署到 msi 和 exe,然后部署到 dmg。当我使用 ant 进行部署时,我创建了应用程序并且安装得很好。但是当你尝试运行它时,它说找不到类中的主要方法。现在,据我所知,您不会将 main 方法放入 gluon 应用程序中,当我尝试将基本 main 方法放入主类中时,我会收到向我抛出的空指针异常。我不确定这里的解决方案是什么,我通过 build.xml 文件提供了该文件,我使用该文件通过 ant 进行部署。

<project name="No Panics Self Helper"
 xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <path id="fxant">
        <filelist>
            <file name="C:\Program Files\Java\jdk1.8.0_91\lib\ant-javafx.jar"/>
            <file name="C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar"/>
        </filelist>
    </path>

    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
        uri="javafx:com.sun.javafx.tools.ant"
        classpathref="fxant"/>

 <delete dir="dist/bundles/NoPanicsSelfHelper/runtime/jre"/>
 <mkdir dir="dist/bundles/NoPanicsSelfHelper/runtime/jre"/>
 <copy todir="dist/bundles/NoPanicsSelfHelper/runtime/jre">
<fileset dir="C:\Program Files\Java\jdk1.8.0_91\jre" />
 </copy>
<fx:deploy nativeBundles="all" width="600" height="400"
       outdir="${basedir}/dist" outfile="NoPanicsSelfHelper">
<fx:application name="NoPanicsSelfHelper" mainClass="com.nopanicsselfhelper.NoPanicsSelfHelper"/>
<fx:resources>
    <!-- include application jars -->
    <fx:fileset dir="dist" includes="NoPanicsSelfHelper.jar"/>       

    <fileset dir="dist/resources">
    <include name="**"/>
    </fileset>
</fx:resources>
<!-- Custom JVM setup for application -->
<fx:platform>
    <fx:jvmarg value="-Xmx2048m"/>
    <fx:jvmarg value="-verbose:jni"/>
</fx:platform>
<fx:platform basedir="${java.home}"/>      
<fx:platform basedir="C:\Program Files\Java\jdk1.8.0_91"/>
<!-- request user level installation -->
<fx:preferences install="false"/>
</fx:deploy>
</project>

最佳答案

答案太简单了。只需添加以下内容即可。

    public static void main(String[] args) {
    launch(NoPanicsSelfHelper.class);
    }

关于java - FX :deploy application not working but the Java jar is working - Gluon Project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45441685/

相关文章:

java - 为什么线程运行不一致?

grails - Grails:运行应用程序错误ant-launcher-1.9.4.pom

java - 如何使用 NetBeans 构建 ant 的 build.xml?

javafx - 如何在基于 Gluon Mobile 的项目上设置图标?

java - Java语言如何在SSL中使用自设计引擎?

java - 在 Android 中使用 Native 的好处

java - 使用java.util.Scanner验证输入

java - 由于 NoSuchMethodError : org. apache.tools.ant.types.resources.Resources.setCache(Z)V,Ant <junit> 任务在 Jenkins 上失败

gradle - 如何改进/更改原始的Gluon Charm Down服务,并在我的应用程序中使用它?

javafx - 任务 'run' 导致 : org. joor.ReflectException : java. lang.NoSuchFieldException: javaExecHandleBuilder - Gluon 移动项目