繁体   English   中英

Jwrapper单罐JavaFX应用ClassNotFoundException

[英]Jwrapper one-jar JavaFX app ClassNotFoundException

我有一个使用Maven的onejar插件构建的独立JavaFX应用程序。 当我运行独立的JAR时,一切都会按预期运行,但是当我使用JWrapper将.jar生成到.exe中时,必须指定主类。 不需要这样做,因为JAR自己运行而无需添加主类作为参数。 在目标Windows机器上,由于ClassNotFoundException(我指定的主类),应用程序无法运行。

这是我的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?

JWrapper不会从类中读取清单,因此您需要指定主类才能运行它。 如果您不知道主要类是什么,可以使用标准的zip工具将jar解压缩(为方便起见,可以将其重命名为.zip),然后在文本编辑器(例如记事本)中打开MANIFEST文件,它将在其中一行中指定主类,您可以将其放入JWrapper。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM