-1

I am using netbeans IDE 7.4. I want to make a jar file with all my dependencies and other image folders along with the jar. How to make a single workable jar file in netbeans or in command tool.

Thanks

Kumar
  • 3,246
  • 4
  • 34
  • 78
  • 1
    You could look at things like [OneJar](http://one-jar.sourceforge.net/) – MadProgrammer Dec 04 '14 at 05:25
  • Can't i do it in netbeans? – Kumar Dec 04 '14 at 05:26
  • 1
    `OneJar` has a Ant task which can be included in your `build.xml` to generate the output as part of your normal build process.. – MadProgrammer Dec 04 '14 at 05:30
  • http://stackoverflow.com/questions/4498047/export-jar-with-netbeans – Ubica Dec 04 '14 at 05:31
  • @Ubica I know to export as jar. I want to export jar with all its dependencies. – Kumar Dec 04 '14 at 05:48
  • @MadProgrammer Thanks. Let me try this. – Kumar Dec 04 '14 at 05:48
  • @madprogrammer.. I followed http://one-jar.sourceforge.net/index.php?page=getting-started&file=quickstart Error A:\tmp\test-one\test>ant 'ant' is not recognized as an internal or external command, operable program or batch file. – BasK Dec 04 '14 at 05:54
  • @Bass you need to set `PATH` variable for windows environment... so that system knows where to find `ant` – Ubica Dec 05 '14 at 00:05
  • @Ubica. I already set path variable. i get other error while execute the below command A:\tmp\test-one\build>java test -jar test-one.jar Error: Could not find or load main class test – BasK Dec 05 '14 at 03:37
  • well something is wrong with your main class, or your main class is not called test :) – Ubica Dec 05 '14 at 04:14

1 Answers1

1

Best would be to use some build tool. Gradle provides java and java-library-distribution plugins that makes distributing artifacts simpler (less code).

Follow this blog for getting started with gradle. It should be simple & quick.

Andy Dufresne
  • 5,424
  • 7
  • 53
  • 86
  • Is there any easy way to do that using command line tool or in netbeans? – Kumar Dec 04 '14 at 05:54
  • Why do you think gradle would not be easy? :) – Andy Dufresne Dec 04 '14 at 06:01
  • I have not yet heard about this and don't know how to work on this. Can you give me sample working tips on this? – Kumar Dec 04 '14 at 06:07
  • Its really good. But for now, i have project in netbeans and just want to export a single jar with all dependencies. As @MadProgrammer said OneJar is a good tool to achieve my requirement. Thanks for your effort. – Kumar Dec 04 '14 at 06:18