Launch4J executable not executing as expected

4.3k views Asked by At

Tools: Win 7, Launch4J 3.5, Simple Hello world Java console app (bundled in a JAR file)

Hello all,

I have a basic JAVA console application that doesn't request any inputs, just a simple application that opens a console window and displays Hello World text.

I built it so simple so I can experiment with Launch4J 3.5 and build an executable file from the jar file.

Everything looks fine, the exe builds successfully but when I launch it nothing happens, I get the hour glass for a few seconds then nothing. I check the Task Manager and there's no process stuck in there.

See my settings in Launch4J, I only filled in the basics, I tried with and without an entry in the Wrapper manifest field:

Output file: C:\Development\SFDC\ProjectX\out\exe\ProjectX.exe

Jar: C:\Development\SFDC\ProjectX\out\artifacts\ProjectX_jar\ProjectX.jar

Wrapper manifest: C:\Launch4j\manifest\uac.exe.manifest (also tried with leaving this blank)

The rest is all left as default.

3

There are 3 answers

0
univise On

If by launching you mean double clicking it, no - nothing you can see will happen; you have to 'tell' Java to run your application with an associated console. To do this, you may create a new .bat file: Simply open a text editor and insert the following line:

java -jar NAME.jar

where "NAME" is the name of your application. Save the text file in .bat format, not in .txt, and place it in the same directory as your application. You can launch your application by double-clicking that file.

The reason it does not pop up in your task manager is because probably (I cannot know) your application only prints out a simple message and does nothing more. In non-console mode, it will just call your print (println or any other console) method without having any visual effect as there is no console to print the message to. In both cases however, if you only print something and do not perform other operations that 'last', such as listening for input, your programm will terminate as it has reached the end of the main method.

0
lbalazscs On

Possibly you need to use launch4j in console mode, see this answer: lauch4j hello world program

0
Carson Graham On

Yes. You do need to use the console mode. You also do need to have some method of keeping the console window open, because it closes the console the moment the program terminates. Use scan.nextLine(); or Thread.sleep(i) if you really need to.