{"id":4165,"date":"2015-01-19T19:52:35","date_gmt":"2015-01-19T19:52:35","guid":{"rendered":"http:\/\/www.jitendrazaa.com\/blog\/?p=4165"},"modified":"2015-01-19T19:57:55","modified_gmt":"2015-01-19T19:57:55","slug":"generating-executable-jar-file-with-all-dependencies-and-libraries-in-single-jar-using-netbeans-and-eclipse","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/generating-executable-jar-file-with-all-dependencies-and-libraries-in-single-jar-using-netbeans-and-eclipse\/","title":{"rendered":"Generating Single Executable jar file with all dependencies and libraries using Netbeans and Eclipse"},"content":{"rendered":"<p style=\"text-align: justify;\">Generating Single <a title=\"Create Executable jar file of classes in package\" href=\"https:\/\/www.jitendrazaa.com\/blog\/java\/create-executable-jar-file-of-classes-in-package\/\">Jar file<\/a> with all dependencies in <strong>Eclipse<\/strong> is easy. We just need to follow below steps :<\/p>\n<ol>\n<li style=\"text-align: justify;\">Either from the context menu or from the menu bar&#8217;s File menu, select Export.<\/li>\n<li style=\"text-align: justify;\">Expand the Java node and select JAR file. Click Next.<\/li>\n<li style=\"text-align: justify;\">In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field.<\/li>\n<li style=\"text-align: justify;\">Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source files and resources. (Note: Selected resources are exported in both cases.<\/li>\n<li style=\"text-align: justify;\">If there are other files or resources you want to include they must be in a an open project. Browse to their location via the directory tree on the left and ensure the file or resource is checked in the window on the right.<\/li>\n<li style=\"text-align: justify;\">In the Select the export destination field, either type or click Browse to select a location for the JAR file.<\/li>\n<li style=\"text-align: justify;\">Select or clear the Overwrite existing files without warning checkbox. If you clear this checkbox, then you will be prompted to confirm the replacement of each file that will be overwritten.<\/li>\n<li style=\"text-align: justify;\">Click Finish to create the JAR file immediately.<\/li>\n<li style=\"text-align: justify;\">Now, navigate to the location you specified for the jar. The icon you see and the behavior you get if you double click it will vary depending on how your computer is set up.<\/li>\n<li style=\"text-align: justify;\">You can use this <a title=\"Creating a jar File in Eclipse\" href=\"https:\/\/www.cs.utexas.edu\/~scottm\/cs307\/handouts\/Eclipse%20Help\/jarInEclipse.htm\" rel=\"nofollow\">article <\/a> for images and more detail.<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>How to generate single jar file in NetBeans with all dependency and libraries :<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">Generating single jar file in eclipse is easy but\u00a0in NetBeans, libraries and dependencies are not automatically combined in one jar file. However there is one time setup required and generating jar file in NetBeans becomes easier than even Eclipse.<\/p>\n<p style=\"text-align: justify;\">Open &#8220;build.xml&#8221; file generated by NetBeans project and add below &#8220;&lt;target&gt;&#8221; tag just before \u00a0 &#8220;&lt;\/project&gt;&#8221; tag.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;target name=&quot;-post-jar&quot;&gt;\r\n    &lt;property name=&quot;store.jar.name&quot; value=&quot;AllInOneJar&quot;\/&gt;\r\n    &lt;property name=&quot;store.dir&quot; value=&quot;dist&quot;\/&gt;\r\n    &lt;property name=&quot;store.jar&quot; value=&quot;${store.dir}\/${store.jar.name}.jar&quot;\/&gt;\r\n    &lt;echo message=&quot;Packaging ${application.title} into a single JAR at ${store.jar}&quot;\/&gt;\r\n    &lt;jar destfile=&quot;${store.dir}\/temp_final.jar&quot; filesetmanifest=&quot;skip&quot;&gt;\r\n        &lt;zipgroupfileset dir=&quot;dist&quot; includes=&quot;*.jar&quot;\/&gt;\r\n        &lt;zipgroupfileset dir=&quot;dist\/lib&quot; includes=&quot;*.jar&quot;\/&gt;\r\n        &lt;manifest&gt;\r\n            &lt;attribute name=&quot;Main-Class&quot; value=&quot;${main.class}&quot;\/&gt;\r\n        &lt;\/manifest&gt;\r\n    &lt;\/jar&gt;\r\n    &lt;zip destfile=&quot;${store.jar}&quot;&gt;\r\n        &lt;zipfileset src=&quot;${store.dir}\/temp_final.jar&quot;\r\n        excludes=&quot;META-INF\/*.SF, META-INF\/*.DSA, META-INF\/*.RSA&quot;\/&gt;\r\n    &lt;\/zip&gt;\r\n    &lt;delete file=&quot;${store.dir}\/temp_final.jar&quot;\/&gt;\r\n&lt;\/target&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Generating Single Jar file with all dependencies in Eclipse is easy. We just need to follow below steps : Either from the context menu or from the menu bar&#8217;s File menu, select Export. Expand the Java node and select JAR file. Click Next. In the JAR File Specification page, select the resources that you want [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3],"tags":[86,287,286],"class_list":["post-4165","post","type-post","status-publish","format-standard","hentry","category-java","tag-eclipse","tag-jar-file","tag-netbeans"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2347,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/hibernate\/step-by-step-hibernate-tutorial-using-eclipse-wtp\/","url_meta":{"origin":4165,"position":0},"title":"Step By Step Hibernate Tutorial Using eclipse WTP","author":"Jitendra","date":"August 8, 2011","format":false,"excerpt":"Step By Step Hibernate (ORM Tool) Tutorial Using eclipse WTP","rel":"","context":"In &quot;Hibernate&quot;","block_context":{"text":"Hibernate","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/hibernate\/"},"img":{"alt_text":"Eclipse Install New Software - Hibernate","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/08\/Eclipse-Install-New-Software-Hibernate.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1984,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/compile-and-run-java-program-in-package-from-command-line\/","url_meta":{"origin":4165,"position":1},"title":"Compile and run Java program in package from command line","author":"Jitendra","date":"April 14, 2011","format":false,"excerpt":"How to Compile JAVA Program in Package from command line","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Java Directory structure","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/04\/Java-Directory-structure.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2274,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/how-to-start-the-tomcat-in-debug-mode-for-debugging-in-eclipse\/","url_meta":{"origin":4165,"position":2},"title":"How to start the tomcat in debug mode for debugging in eclipse","author":"Jitendra","date":"June 21, 2011","format":false,"excerpt":"This is the tutorial on How to start the tomcat in debug mode for debugging in eclipse","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5873,"url":"https:\/\/www.jitendrazaa.com\/blog\/sql\/sqlserver\/export-documents-saved-as-blob-binary-from-sql-server\/","url_meta":{"origin":4165,"position":3},"title":"Export Documents saved as Blob \/ Binary from SQL Server","author":"Jitendra","date":"December 24, 2016","format":false,"excerpt":"T-SQL Scripts to Export Blob or Binary data stored in SQL Server","rel":"","context":"In &quot;SQL Server&quot;","block_context":{"text":"SQL Server","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/sql\/sqlserver\/"},"img":{"alt_text":"SQL Server Export Blob as File","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/12\/SQL-Server-Export-Blob.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/12\/SQL-Server-Export-Blob.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/12\/SQL-Server-Export-Blob.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/12\/SQL-Server-Export-Blob.gif?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":949,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/backup-the-salesforce-data\/","url_meta":{"origin":4165,"position":4},"title":"Schedule export backup of your Salesforce Data &#8211; Interview Question","author":"Jitendra","date":"September 2, 2010","format":false,"excerpt":"How to schedule export backup of salesforce data - Very common interview question","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1993,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/create-executable-jar-file-of-classes-in-package\/","url_meta":{"origin":4165,"position":5},"title":"Create Executable jar file of classes in package","author":"Jitendra","date":"April 14, 2011","format":false,"excerpt":"Create Executable jar file of classes in package","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/4165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=4165"}],"version-history":[{"count":4,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/4165\/revisions"}],"predecessor-version":[{"id":4169,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/4165\/revisions\/4169"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=4165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=4165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=4165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}