JavaFX应用程序无法使用本机exe包启动

我已经构建了一个可以通过其jar文件执行的JavaFX应用程序。 但是,如果我尝试使用本机exe包运行它,我收到两个弹出窗口:

  • com / npap / dicomrouter / Main – 没有主类

  • 无法启动JVM

并且应用程序无法启动。

这是我的Main类(大部分内容):

package com.npap.dicomrouter; public class Main extends Application { ... public static void main(String[] args) throws IOException { try { JUnique.acquireLock(appId); alreadyRunning = false; log.info("application is going to start running!!!!"); } catch (AlreadyLockedException e) { alreadyRunning = true; log.info("application is already running!!!!"); } if (!alreadyRunning) { Application.launch(Main.class, (java.lang .String[])null); } } @Override public void start(Stage primaryStage) throws IOException { ... try { AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("FXMLDocument.fxml")); Scene scene = new Scene(page, initWidth, initHeight); primaryStage.setScene(scene); Platform.setImplicitExit(false); createTrayIcon(primaryStage); primaryStage.setTitle(appTitle); primaryStage.show(); } catch (IOException ex) { log.log(Level.INFO, null, ex); } } 

我的build.xml以这种方式配置:

          

我正在使用Netbeans构建应用程序(Java FX 2.1),其方式如下:

https://netbeans.org/kb/docs/java/native_pkg.html

我已成功构建和运行本机exe包的其他javafx应用程序。 我还附上了一个屏幕截图,显示了我如何声明主项目的类。

在此处输入图像描述

所以我深刻地假设这是一个项目特定的问题。 在控制台中构建期间,我得到:

 The jar lib\hibernate-commons-annotations-4.0.2.Final.jar has a main class org.hibernate.annotations.common.Version that does not match the declared main com.xxxx.yyyy.Main The jar lib\javassist-3.15.0-GA.jar has a main class javassist.CtClass that does not match the declared main com.xxxx.yyyy.Main The jar lib\h2-1.3.176.jar has a main class org.h2.tools.Console that does not match the declared main com.xxxx.yyyy.Main 

除了这些jar之外,我还使用了其他几个包含“main”方法的类(可运行)。

 @SuppressWarnings("unchecked") public static void main(String args[]) throws Exception { ... 

其中大多数是第三方实用程序类。

我也正在添加package.cfg文件的内容,仅供参考:

 app.mainjar=DicomRouterAffidea0_2_2.jar app.version=1.0 app.id=com.npap.dicomrouter app.preferences.id=com/npap/dicomrouter app.mainclass=com/npap/dicomrouter/Main app.classpath=lib/antlr-2.7.7.jar lib/c3p0-0.9.2.1.jar lib/clibwrapper_jiio.jar ..... ... //jars listing 

最后,我附上了Libraries,Compiling and Deployment Netbeans配置的3个屏幕截图。 希望也可以帮助:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

回答我的问题,因为经过一些试验后,我设法通过从build.xml中删除代码来构建一个function性的.exe文件。

所以我从build.xml中删除了所有这些行:

         

我只是导入: