0

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 を実行するにはどうすればよいですか?

4

1 に答える 1

2

JWrapper はクラスからマニフェストを読み取らないため、実行するメイン クラスを指定する必要があります。メイン クラスがわからない場合は、標準の zip ツールを使用して jar を解凍し (必要に応じて名前を .zip に変更して簡単に解凍できます)、テキスト エディター (メモ帳など) で MANIFEST ファイルを開くことができます。行の1つでメインクラスを指定し、それをJWrapperに入れることができます。

于 2015-11-10T18:23:13.033 に答える