Launch4J - how to attach dependent jars to generated exe

前端 未结 7 908
深忆病人
深忆病人 2020-11-28 13:43

I have a simple java project, which requires external jars. I build this with netbeans and after Clean and Build command, I can find in dist directory the following structur

7条回答
  •  抹茶落季
    2020-11-28 14:21

    As it often happens being unable to solve the problem I published it on StackOverflow ... and pretty soon after publishing the question I got an idea.

    So the answer to my question is:

    Put all the dependent jars into one main jar.

    It took me some time to find info how can I do that.

    To help people I decided to publish detailed instruction here - they are based on Netbeans 7.4.

    1. Following article from http://mavistechchannel.wordpress.com/2010/08/17/how-to-build-a-single-jar-file-with-external-libs/ I created the ant script that build one-jar-app for me. I could then manually create exe via Launch4J

    2. I then decided that I want more automated task, and I did that, Ant builds exe for me (via Launch4J)

    3. Then I realized that I must do "clean and build" before my automated task (in point 2)/ I decided that I want clean and build to be done automatically before the exe build

    Putting all together I am attaching my ant build script consisting of points 1,2,3:

    It is required to edit build.xml and put the content found below before "project" end tag

    
        
        
        
        
        
        
        
        
        
            
            
            
            
            
        
        
            
        
        
        
    
    

    then in Netbeans rightclick on the build.xml and choose: Run Target / Other Targets / package-for-launch4j

    exe file is ready in exe folder :-)

提交回复
热议问题