fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 134 forks source link

Problems packaging a normal project in Maven #210

Closed JoseJuan1011 closed 2 years ago

JoseJuan1011 commented 2 years ago

I'm submitting a…

Short description of the issue/suggestion:

I'm having trouble trying to package an app using the minimal configuration, because it says that I don't have the candle installed.

Steps to reproduce the issue/enhancement:

  1. [First Step] Put the plugin in the pom.xml of the project
  2. [Second Step] Install the plugin via Maven Central
  3. [Other Steps...] Package the project

What is the expected behavior?

It will create the executable without giving any exeptions.

What is the current behavior?

It gives an error saying that candle as a command doesn't exist.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

This is my plugin configuration:

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>1.6.6</version>
    <executions>
        <execution>
            <phase>package</phase>
                <goals>
                    <goal>package</goal>
                </goals>
            <configuration>
                <mainClass>fvarrui.sample.Main</mainClass>
                <bundleJre>true</bundleJre>
            </configuration>
        </execution>
    </executions>
</plugin>

And this is the error on the output:

[ERROR]         'candle' is not recognized as an internal or external command,
[ERROR]         operable program or batch file.
[ERROR]     MSI installer generation failed due to: Command execution failed: candle -out C:\Users\micro\OneDrive\Docum
entos\2_DAM_A_2021-2022\DAD\ConejitosFX\target\assets\ConejitosFX.msm.wixobj C:\Users\micro\OneDrive\Documentos\2_DAM_A
_2021-2022\DAD\ConejitosFX\target\assets\ConejitosFX.msm.wxs
[ERROR]
org.codehaus.plexus.util.cli.CommandLineException: Command execution failed: candle -out C:\Users\micro\OneDrive\Docume
ntos\2_DAM_A_2021-2022\DAD\ConejitosFX\target\assets\ConejitosFX.msm.wixobj C:\Users\micro\OneDrive\Documentos\2_DAM_A_
2021-2022\DAD\ConejitosFX\target\assets\ConejitosFX.msm.wxs
    at io.github.fvarrui.javapackager.utils.CommandUtils.execute (CommandUtils.java:19)
    at io.github.fvarrui.javapackager.utils.CommandUtils.execute (CommandUtils.java:25)
    at io.github.fvarrui.javapackager.packagers.GenerateMsm.doApply (GenerateMsm.java:59)
    at io.github.fvarrui.javapackager.packagers.GenerateMsi.doApply (GenerateMsi.java:40)
    at io.github.fvarrui.javapackager.packagers.GenerateMsi.doApply (GenerateMsi.java:16)
    at io.github.fvarrui.javapackager.packagers.ArtifactGenerator.apply (ArtifactGenerator.java:44)
    at io.github.fvarrui.javapackager.packagers.Packager.generateInstallers (Packager.java:436)
    at io.github.fvarrui.javapackager.maven.PackageMojo.execute (PackageMojo.java:370)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.ja
va:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

What is the motivation / use case for changing the behavior?

Because I want to create an executable for other person to use the app.

Please tell us about your environment:

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

fvarrui commented 2 years ago

Hi @VegasBeats!

You have to install WiX Toolset on your Windows system as it includes the candle and light tools used by JavaPackager to generate MSI installers.

It's explained in docs:

image

There's also a guide explaining how to install it easily.

Thanks for using JavaPackager!

fvarrui commented 2 years ago

Oh! If you prefer, you can also skip the MSI generation with winConfig.generateMsi=false

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>1.6.6</version>
    <executions>
        <execution>
            <phase>package</phase>
                <goals>
                    <goal>package</goal>
                </goals>
            <configuration>
                <mainClass>fvarrui.sample.Main</mainClass>
                <bundleJre>true</bundleJre>
                                <winConfig>
                                        <generateMsi>false</generateMsi>
                                </winConfig>
            </configuration>
        </execution>
    </executions>
</plugin>
JoseJuan1011 commented 2 years ago

At the end I have used the second option, but I don't know why I can't execute it, I have used the configuration that you have specified, the app executes itself when I compile it with maven and execute it and it works perfectly. Then I package it and install it with the exe, and it doesn't work either normal or with the installation process. Thanks in advance.

fvarrui commented 2 years ago

You can see what is going wrong with your EXE by setting winConfig.headerType=console and running you app from a terminal. Are you using JavaFX or resources embedded in your app (resources/some.file)?

fvarrui commented 2 years ago

You can also try running the generated JAR, because if it doesn't work, your EXE won't either. If you run the runnable JAR, it needs you copy libs folder next to it before running.

JoseJuan1011 commented 2 years ago

Currently im using JavaFx on the app, and I have saw that the exe has problems with the javafx views unfortunately, so what should I do in case of a JavaFx App?

fvarrui commented 2 years ago

Please, could you share here the error message?

JoseJuan1011 commented 2 years ago

I have the log with the errors, so here you have them, it's a mix beetween javafx and other errors maybe because problems with javafx properties in background. Conejitos.log

fvarrui commented 2 years ago

I've just realized that you are JJ 😃 ... Do you have your project on a public repo?

JoseJuan1011 commented 2 years ago

I can invite you to my private repo, where I have the project that Im having trouble making the executable with.

JoseJuan1011 commented 2 years ago

Look at your invitations, I have sent you an invitation for it.

fvarrui commented 2 years ago

Ok, I'll try to have a look into it ASAP

JoseJuan1011 commented 2 years ago

At the end the problem was that I didn't put an Upper Case where I needed to (JavaFx view route declaring the loader), that was for solving the first issue.

And the second, which didn't let me use the login, was because the javapackager sometimes doesn't package (for everyone's understanding) some libraries, so it's important to put the following lines of code in case you have a related issue, where there's a problem in passing data from Interface to Backend, between other related issues:

<customizedJre>false</customizedJre>