aspose file tools*
The moose likes Java in General and the fly likes Single jar deployment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Single jar deployment" Watch "Single jar deployment" New topic
Author

Single jar deployment

john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
When using Netbeans 7.0.1, deploying a gui desktop application is as simple as hitting the 'hammer and broom' icon, which says 'clean and build main project'. However this does not produce a single jar file. Instead you get a lib folder as well where various dependency jar files are lodged. I wish to deploy a single jar file. So no lib folder. Just a single executable jar file. How can I do this??

I already tried the solution found at this site:
http://192.9.162.55/developer/technicalArticles/java_warehouse/single_jar/

But it does not work. Any ideas?
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 294
    
    2

That works for me (as i said on the NetBeans forum).

What kind of problems are you having?

A couple of things to note.
  • You can't just cut and paste that code into your build.xml file you have some editing to do
  • That script is not automaically run when you clean and build you have to explicitly run it
  • That script does not merge manifests so if you put something significant in there you have to make sure the main manifiest goes in last


  • I wish NetBeans would take care of this like Eclipse does but it seems to violate someones sense of fair play. I suppose some of the libraries may not have licenses that allow this.

    Joe


    It's not what your program can do, it's what your users do with the program.
    john gere
    Greenhorn

    Joined: Mar 10, 2011
    Posts: 22
    Are you suggesting that I have to clean and build my project, then save this script to a build.xml and run 'ant' from the command line? That I have not done. I assumed I had to copy and paste to either the build.xml or the build-impl.xml. I actually tried both and it failed. So now I guess I have to run a 'clean and build' in netbeans, then put this script in a build xml file in the dist folder and then run it from the command line using ant. Given that ant looks for a build file, I just have to type in ant.

    Is that about correct??
    Joe Areeda
    Ranch Hand

    Joined: Apr 15, 2011
    Posts: 294
        
        2

    arima kidd wrote:Are you suggesting that I have to clean and build my project, then save this script to a build.xml and run 'ant' from the command line? That I have not done. I assumed I had to copy and paste to either the build.xml or the build-impl.xml. I actually tried both and it failed. So now I guess I have to run a 'clean and build' in netbeans, then put this script in a build xml file in the dist folder and then run it from the command line using ant. Given that ant looks for a build file, I just have to type in ant.

    Is that about correct??
    Not quite.

    Once you put it in the build.xml script it will stay there. I do not modify build-impl.xml I think that one does get recreated when you change project parameters but I'm sure the build.xml does not.

    What I do (and I don't claim it's the best let alone the only way) is clean an build, then right click on build.xml in the Files view (I know) and choose Run Target -> Run Other Target-> Package for Store.

    There is probably a better way but by the time I'm ready to do this, I usually don't have enough energy left to look for one.

    Joe
    john gere
    Greenhorn

    Joined: Mar 10, 2011
    Posts: 22
    Thanks a million. WoW! I never thought I would get such an easy and simple solution. Was about to brace myself for a few days reading on using Ant with OneJar. Thanks again.! Now it's off to learning how to sign my jars for copyright purposes.
    Joe Areeda
    Ranch Hand

    Joined: Apr 15, 2011
    Posts: 294
        
        2

    You're welcome.

    Joe
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Single jar deployment
     
    Similar Threads
    Creating jar files with Netbeans
    A Struts Internationalization Example Problem
    unable to connect to mysql using jsp
    Trying to execute java program which is in jar file
    JBoss Classpath