Creating a windows .exe from a runnable jar (prefe

2019-07-27 18:52发布

问题:

I have an application packaged up as a xyz.jar, which can be run as java -Xmx2g -jar xyz.jar

How can I convert this to a self-contained exe that can be downloaded by Windows users and launched with a single click? Preferably, I'd like the jre also bundled inside the exe, much like can be done from the mac: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

Oh, and also I'd prefer if I can do this from an ant build file (or eclipse plugin) on a mac or linux platform, since I don't have easy access to Windows (though my users do). Is this possible? Thanks.

回答1:

Take a look at Launch4J, it's cross platform so you should be able to generate the executable from any platform your build is running on. IIRC it also have an ANT task ready to be used.

http://launch4j.sourceforge.net/