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

The installed program can't run if set project name with Chinese #358

Closed JungleHH closed 1 year ago

JungleHH commented 1 year ago

I'm submitting a…

I used JavaPackager to build my Javafx project which project.name is in Chinese. The build process smoothly without any error log. The install process run well too. Normally displayed dialog in Chinese. But after installing, the program don't run when I double click it. I guess the reason is the path include encode in Chinese somewhere. So, I change my project.name to English. Everything is OK.

Here is the detail of installation path: -customJRE -libs -resources -我的软件.exe -我的软件.l4j.ini -我的软件-1.0.0.0-runnable.jar

If you need more information, I will show my maven content here! Thanks for your JavaPackager. It rescues me from Wix marsh! : )

fvarrui commented 1 year ago

Hi @JungleHH!

But after installing, the program don't run when I double click it.

I guess you are generating your EXE with launch4j ... as far as i know, using chinese characters only affects the metadata of the executable, not its execution. I think that using winrun4j or why instead of launch4j fixes these metadata problems.

Please, could you try the following?: set winConfig.headerType=console, build your app a run EXE again. Maybe this throws some light about what's really happening.

fvarrui commented 1 year ago

Thanks for your JavaPackager. It rescues me from Wix marsh! : )

Thanks!! Really appreciate these comments 😄

JungleHH commented 1 year ago

Thanks for your suggestion! I have tried winrun4j and why, but it still not works. winrun4j: the problem was same as above. why: When I open it after building and installing, why I have set winConfig.headerType=console, but the console window flash across, maybe some error shut it down. Does it mean that there may be something else cause it.

lhDream commented 1 year ago

@JungleHH 我用 launch4j还挺正常的,看看你配置

JungleHH commented 1 year ago

@lhDream 好吧,除了POM配置外,我还怀疑与IDEA或操作系统的字符集有关。有些情况下,当文件被工具链创建时它可能会被写入声明文件编码信息的BOM字节头,但是我还没有验证这个结论。 All right, I suspect the issue may be related to the OS or IDEA character set. Under certain conditions, some BOM byte for declaring file encode will be written into file header when it is created by the toolchain. But I have not verified this guess yet. Here is my POM conf:

<plugin>
                <groupId>io.github.fvarrui</groupId>
                <artifactId>javapackager</artifactId>
                <version>1.7.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <!-- mandatory -->
                            <mainClass>app.mechanical.Main</mainClass>
                            <!-- optional -->
                            <bundleJre>true</bundleJre>
                            <generateInstaller>true</generateInstaller>
                            <administratorRequired>false</administratorRequired>
                            <assetsDir>${projectdir}/assets</assetsDir>
                            <bundleJre>true</bundleJre>
                            <copyDependencies>true</copyDependencies>
                            <customizedJre>true</customizedJre>
                            <displayName>${project.name}</displayName>
                            <forceInstaller>true</forceInstaller>
                            <jdkPath>${java.home}</jdkPath>
                            <jreDirectoryName>customJRE</jreDirectoryName>
                            <!-- resources file -->
                            <additionalResources>
                                <additionalResource>${project.basedir}/${project.name}.l4j.ini</additionalResource>
                                <additionalResource>${project.build.directory}/conf/</additionalResource>
                                <additionalResource>${project.build.directory}/css/</additionalResource>
                                <additionalResource>${project.build.directory}/data/</additionalResource>
                                <additionalResource>${project.build.directory}/fxml/</additionalResource>
                                <additionalResource>${project.build.directory}/images/</additionalResource>
                                <additionalResource>${project.build.directory}/log/</additionalResource>
                                <additionalResource>${project.build.directory}/META-INF/</additionalResource>
                                <additionalResource>${project.build.directory}/meta.properties</additionalResource>
                            </additionalResources>
                            <modules>java.base,java.logging,jdk.unsupported,java.desktop,java.scripting,java.xml,java.naming</modules>
                            <packagingJdk>${java.home}</packagingJdk>
                            <name>${project.name}</name>
                            <version>${project.version}</version>

                            <outputDirectory>${project.build.directory}/output</outputDirectory>
                            <platform>windows</platform>
                            <winConfig>
                                <!-- general properties -->
                                <icoFile>src/main/resources/images/app.ico</icoFile>
                                <generateSetup>true</generateSetup>
                                <generateMsi>false</generateMsi>
                                <generateMsm>false</generateMsm>

                                <!-- exe creation properties -->
                                <headerType>console</headerType>
                                <wrapJar>false</wrapJar>
                                <companyName>${project.organization.name}</companyName>
                                <fileDescription>${project.description}</fileDescription>
                                <productVersion>${project.version}</productVersion>
                                <txtProductVersion>${project.version}</txtProductVersion>
                                <copyright>xxxxxxxx</copyright>
                                <productName>${project.name}</productName>
                                <internalName>${project.name}</internalName>
                                <originalFilename>${project.name}-${project.version}.exe</originalFilename>

                                <!-- choose EXE creation tool -->
                                <exeCreationTool>launch4j</exeCreationTool>

                                <!-- setup generation properties -->
                                <setupMode>installForAllUsers </setupMode>
                                <language>zh_CN</language>
                                <setupLanguages>
                                    <ChineseSimplified>compiler:Languages\ChineseSimplified.isl</ChineseSimplified>
                                </setupLanguages>
                                <disableDirPage>false</disableDirPage>
                                <disableProgramGroupPage>true</disableProgramGroupPage>
                                <disableFinishedPage>false</disableFinishedPage>
                                <disableRunAfterInstall>true</disableRunAfterInstall>
                                <disableWelcomePage>true</disableWelcomePage>
                                <createDesktopIconTask>true</createDesktopIconTask>
                                <removeOldLibs>true</removeOldLibs>
                            </winConfig>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
lhDream commented 1 year ago

@JungleHH 你使用fxml的话,可能是jfx自己的问题,打包后,用 java -jar yourAppName.exe看看错误信息

lhDream commented 1 year ago

jfx自己对中文的支持也是....一言难尽.....

lhDream commented 1 year ago

@JungleHH 怎么样了?是不是这个问题

JungleHH commented 1 year ago

@lhDream

@JungleHH 怎么样了?是不是这个问题

还没,最近在忙其他事情,等我验证出来了我会回来 Not yet, I've been busy with other things. I'll reply here when I figure it out.

JungleHH commented 1 year ago

Hey guys, I can't reproduce the issue any more after using it several months. It works well with Launch4j actually. So I will close this issue. @fvarrui @lhDream thank you!