开发者

Running Launch4J from java code?

开发者 https://www.devze.com 2023-04-03 02:38 出处:网络
I have used launch4j to wrap an executable jar into an exe in my pom.xml (maven project file) file during compile/build time.

I have used launch4j to wrap an executable jar into an exe in my pom.xml (maven project file) file during compile/build time.

But is it possible to run launch4J from a piece of java code and creating an exe wrapper dynamically when the java application is executed, like:

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);
        ...
       l4jCo开发者_如何学编程nfig.create();
  }
}

Any pointers or links to examples are welcome!


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!
0

精彩评论

暂无评论...
验证码 换一张
取 消