问题
Launch4j seems to simple to setup but after the exe has been generated it wouldn't run from another location.
The jar file used to create the launcher still needs to be in the same folder as the exe is.
I thought it would have wrapped the jar in exe and could run it from anywhere? I have done this with JSmooth before and it worked well. But JSmooth isn't supported on Windows 7 anymore.
Also could not find any proper documentation for it.
What is going wrong here.
Thanks, Shankar.
回答1:
Your simple scenario works for me. The only options I needed to fill in were Output file, Jar and Min JRE version. Everything else is left as default.
It's important to have all your external libraries packed into the JAR and not into a folder next to the generated JAR. To achieve that, select "Extract required libraries into generated JAR" option in Eclipse when exporting runnable JAR.
回答2:
If we are talking about the JAR containing the main class, then this is configurable: http://launch4j.sourceforge.net/docs.html#Configuration_file
What you want to set is dontWrapJar to true
, but this is the default value so you had to change something if it's not in the EXE. When toggling this boolean, one can clearly see the size difference (e.g. in my case it's 40K without JAR and 56 with 16K JAR included, also in Total Commander I can use Ctrl+PgDn to enter the EXE as any other ZIP if it has JAR included).
In POM file when using com.akathist.maven.plugins.launch4j:launch4j-maven-plugin
plugin the option is named the same - dontWrapJar
. In that case jar
option must point to the built JAR (in target), because it is relative to EXE (and both goes to target) in most cases it's just the name of the JAR. While the JAR is lying next to the EXE, it is not necessary to run the EXE and can be removed to check it.
This does not tell anything about other dependencies for which there are other options and if you need everything in EXE than you need to use some uberjar solution.
来源:https://stackoverflow.com/questions/16391562/launch4j-exe-still-needs-the-jar-file