簡體   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