Exécution Launch4j à partir du code java?
Question
J'ai utilisé launch4j pour envelopper un pot exécutable dans un exe dans mon fichier pom.xml (fichier Maven) lors de la compilation / construction.
Mais est-il possible d'exécuter Launch4j à partir d'un morceau de code Java et la création d'une enveloppe exe dynamiquement lorsque l'application Java est exécutée, comme:
import some.l4j.dependencies.*;
public class L4JTest {
public static void main(String[] args) {
Launch4JConfig l4jConfig = new Launch4JConfig ();
l4jConfig.setJarPath("path-to-jar-to-wrap");
l4jConfig.setOutfile("test.exe")
l4jConfig.setDontWrapJar(true);
...
l4jConfig.create();
}
}
Les pointeurs ou des liens vers des exemples sont les bienvenus!
La solution
Since you did not want to go thorough the Runtime.getRuntime().exec(..)
way, you will have to tinker around. We have used launch4J and we never had the use-case that you are looking for. I do not think launch4J has a documented Java API.
However, you may tinker with the Ant task used in launch4J and use it for your purpose here. Have a look at the task's source
You will see that it makes use of net.sf.launch4j.Builder
and net.sf.launch4j.config.Config
to "build" the EXE.
- good luck!