我有一个使用 Maven 的onejar插件构建的独立 JavaFX 应用程序。当我运行独立 JAR 时,一切都按预期运行,但是当我使用 JWrapper 将 .jar 构建到 .exe 中时,我必须指定主类。这不应该是必需的,因为 JAR 自己运行而无需添加主类作为参数。由于 ClassNotFoundException(我指定的主类),目标 Windows 机器上的应用程序无法运行。
这是我的 jwrapper.xml:
<JWrapper>
<!-- The name of the app bundle -->
<BundleName>MyApp</BundleName>
<!-- The specification for one app within the bundle -->
<App>
<Name>MyApp</Name>
<MainClass>main.Main</MainClass>
<LogoPNG>AppIcon.png</LogoPNG>
</App>
<SupportedLanguages>en</SupportedLanguages>
<SplashPNG>AppIcon.png</SplashPNG>
<BundleLogoPNG>AppIcon.png</BundleLogoPNG>
<!-- App is a per-user app, it won't elevate and install for all users and the shared config folder will be per-user -->
<InstallType>CurrentUser</InstallType>
<!-- The JREs JWrapper should use for Windows, Linux32, Linux64... -->
<Windows32JRE>JREs/windows-x86-jre1.8.0_60</Windows32JRE>
<Windows64JRE>JREs/windows-x64-jre1.8.0_60</Windows64JRE>
<Linux32JRE>JREs/linux-x32-jre1.8.0_60</Linux32JRE>
<Linux64JRE>JREs/linux-x64-jre1.8.0_60</Linux64JRE>
<Mac64JRE>JREs/osx-x64-jre1.8.0_60.jre</Mac64JRE>
<!-- The files that the app wants to bundle, here we have just one which is a JAR file and we specify that it should be on the launch classpath -->
<File classpath='yes'>MyApp.one-jar.jar</File>
<!-- Skip OSX -->
<SkipMacOS>true</SkipMacOS>
<SkipLinux>true</SkipLinux>
</JWrapper>
如何使用 Jwrapper 运行单个 JAR?