The .exe I created with Launch4j doesn't run
Asked Answered
C

5

5

I was able to successfully create a .exe file from an executable jar. From Launch4j I can test the wrapper, and the output on the log is what I expect. However if I try to run the exe from the command line or from Windows Explorer, nothing happens. No error, no output to the console as expected. The program is also supposed to edit a text file which does happen when I run the jar using a batch file, but not when I run the exe. This is all on the same computer so I doubt it is a problem with the JRE. I have searched StackOverflow extensively but found nothing that helps with this situation. I did find this post with a similar problem: Launch4J executable not executing as expected but nobody actually answered the question. Thank you in advance for helping

Cliquish answered 30/6, 2015 at 23:20 Comment(1)
Here's another question. Its answer may not help you, but there's a comment that indicates removing the <classpath> configuration entry helped. #2068633Otiose
C
10

I found the issue. Under Header, I had to switch the Header type from GUI to Console. After that I was able to run the exe.

Cliquish answered 30/6, 2015 at 23:59 Comment(1)
For me this didn't change the fact that the application was quietly crashing, but it does let you find the error. In my case I was wrapping my jar without 3rd party library dependencies, and that's why it was failing. After packaging the correct jar I was able to run (with console or gui mode).Odor
P
1

You may be accepting something as a command line argument which may be throwing an error like in my case .

Prospectus answered 3/2, 2016 at 10:44 Comment(0)
C
0

For my case, it was the tick on "Signle Instance" tab: Allow only a single instance of the application. Although I had killed the process, for some unknown reason the exe had been recognized as alive. Thus, a reboot of the PC is recommended.

Cerberus answered 18/1, 2021 at 7:53 Comment(0)
A
0

These are the things I had to do for it to work on Windows 10:

First, make sure the executable JAR you created actually executes. I could never got the JAR to execute by double-clicking. Instead, I created a .bat file where I added the java -jar command-line instruction to execute the jar, including the VM arguments. For example, to execute foo.jar, the .bat file should contain java -jar --module-path %FX_HOME% --add-modules javafx.controls,javafx.fxml foo.jar. Once you get the JAR to execute without errors (pay attention to the command prompt window), then your JAR is ready. Then, do the following from the Launch4J app:

  1. Create FX_HOME environment variable. Make sure it points to the lib folder of the downloaded Java FX distribution is located.*
  2. Set JAVA_HOME environment variable.*
  3. Make sure JAVA_HOME is the first entry on the Path variable. Verify by opening a command prompt and typing where java and hitting the ENTER key.
  4. Under Header, make sure "GUI" is selected.
  5. Under JRE, set Bundled JRE paths to %JAVA_HOME%.
  6. Under VM Option, enter --module-path %FX_HOME% --add-modules javafx.controls,javafx.fxml

*If any of the paths contain spaces, make sure they are in quotes when you create the environment variable. For example: C:\Program Files\Java 17\bin, should be in quotes. This is because the command-line parameters are space-delimited and "Program Files" contains a space, fooling the command-line interpreter to think Program is the end of one parameter and Files is the beginning of another. By putting in quotes, the interpreter now knows the space is part of that single parameter that represents the path.

Adventure answered 1/4, 2022 at 22:1 Comment(0)
C
0

In my case, under Basic tab in Options section I checked "Stay alive after launching GUI application" (this doesn't work).

Instead I switched to jSmooth.

Choleric answered 19/9, 2023 at 22:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.