java - Jwrapper 一 jar JavaFX 应用程序 ClassNotFoundException

标签 java maven deployment javafx jwrapper

我有一个使用 Maven 构建的独立 JavaFX 应用程序 onejar插入。当我运行独立 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 不会从类中读取 list ,因此您需要指定主类才能运行。如果您不知道主类是什么,您可以使用标准 zip 工具解压缩 jar(如果需要,您可以将其重命名为 .zip),然后在文本编辑器(例如记事本)中打开 MANIFEST 文件,它将在其中一行指定主类,您可以将其放入 JWrapper 中。

关于java - Jwrapper 一 jar JavaFX 应用程序 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33187720/

相关文章:

java - 使用 spring 验证来验证对象的特殊字符

django - 我已经在 pythonanywhere 中部署了我的 django 项目,DATABASES is improperly configured 错误

azure - 将 umbraco 部署到 Azure

java - 带有 Android 的 Azure 移动服务

java - 用于验证 64 位(8 字节)MAC 地址的正则表达式?

java - Android 库错误

java - 从资源java中读取文件时出现空指针异常

maven - 在 maven 仓库中安装 tar.gz 文件

eclipse - maven构建时如何覆盖WAR文件中的文件?

iOS:无法将应用程序安装为 IPA