0

I have a standalone JavaFX application built using Maven's onejar plugin. When I run the standalone JAR everything runs as expected, but when I build the .jar into .exe with JWrapper I have to specify the main class. This should not be needed, since the JAR runs on its own without adding the main class as parameter. On target windows machine app fails to run due to ClassNotFoundException (the main class I specified).

Here is my 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>

How do I run a single JAR with Jwrapper?

Ghostli
  • 383
  • 1
  • 3
  • 11

1 Answers1

2

JWrapper doesn't read the manifest from the class so you will need to specify the main class for it to run. If you don't know what the main class is you can unzip the jar using a standard zip tool (you can rename it to .zip if necessary to facilitate this) and then open the MANIFEST file in a text editor (e.g. notepad), it will specify the main class on one of the lines and you can put that into JWrapper.

AntonyM
  • 1,602
  • 12
  • 12
  • The problem was that even if I specified the main class for Jwrapper the exception was thrown. However I solved this issue simply by getting rid of OneJar and packing every single jar independently into the final product. I also had to turn Pack200 effort off to avoid some further errors. It works perfectly now, thanks for feedback. – Ghostli Nov 12 '15 at 09:10