Pages

Subscribe:

Ads 468x60px

Tuesday, August 16, 2011

How to build a fat jar using Netbeans

Hmm after long time with out blogging. Finally decided to add some posts to my blog. So in this post I would like to describe how to build a fat jar using NetBeans. Of course you can simply do it using Eclipse. But in Netbeans you can't actually directly build a fat jar. The jar which is build using NetBeans is not adding the libraries you've used for the project. The libraries are added to a folder called "lib" whenever you run the jar the "lib" folder must be in the same directory.

So lets get started building a fat jar using Netbeans. The first thing you have to do is clean and build the project.

Then go the Files view of the Project and open the build.xml file.

Then copy and paste the following code just before the " project" tag ends.

Download file from here DOWNLOAD FILE

Then it's almost done. Now in files view of the project right click build.xml file and then select Runtarget >> Other Targets >> package-for-store.

That's it now your fat jar has been created. Go to your project folder and check the folder called store. Inside that folder you can see your fat jar.

That's it now you know how to build a fat jar using NetBeans. If you need any help just put a comment. Cheers :)

18 comments:

  1. This one solved a problem of mine, mate :) Keep up the good work

    ReplyDelete
  2. When stealing an article, at least link the original.
    http://www.oracle.com/technetwork/articles/javase/single-jar-141905.html

    ReplyDelete
  3. @Unknown I didn't steal it. I got the script from one of my seniors.. Anyway thanks for reference.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Great Help !! Thanks a lot :)

    ReplyDelete
  6. very thanks, therefore I can access this article by way of google . Oracle web site does'nt apper in searching

    ReplyDelete
  7. I get this great post via stackoverflow, thanks a lot!

    ReplyDelete
  8. Thanks this works like charm

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. shows "unable to find application class name" for javafx desktop application.............plz help

    ReplyDelete
  11. Great Post. Followed the steps and it worked like a charm. Thanks.

    ReplyDelete
  12. Thanks a lot! Worked perfectly

    ReplyDelete
  13. Hiii...
    I am using NetBeans IDE 7.4. In which I am facing same problem.
    When I am trying same solution which is provided by author, I am not getting that option "Package-for-Store".

    Please HELP ME..!!!!
    Thanks in advance

    ReplyDelete
  14. hii..Aruna Karunarathna. i got a an error while ruuning the "one jar",error Could not found or load main class$(main.clss).i changed class name also stil its showing same error ,can you please tel me whtas wrong with me.,,Thank you

    ReplyDelete