• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I convert my Java project to an jar file with all the external libraries.  RSS feed

 
Gautam Muktsar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have converted my java project into jar file by NetBeans and gave it to my friend . Whenever he click on that jar he is getting exception and then i have tried from cmd to run it then it was showing error like iText.pdf.* missing .

It means in that jar file the external library which i have used in my project is not there . so guys please give me a solution that how i convert my java project along with the external library which i have used in project

Thanks in advance
 
Carey Brown
Saloon Keeper
Posts: 3317
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You showed an error where a .pdf file was not found, does it exist where your program is looking for it? Is it a "resource" included in your .jar file?
To answer your general question about including external jars in the final jar, I don't know about NetBeans, but with Eclipse, Maven, and a plugin it is doable.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Maven, check out the Shade Plugin. Like One-JAR it creates one JAR file, but unlike One-JAR it doesn't put the dependencies as JAR files inside a JAR file with a custom class loader, but it just creates a regular JAR file which means you can also use it to create JAR files that you can use in other projects. Also, the JAR files can have multiple classes with main methods that you can use just by specifying the JAR file as the class path: java -cp <shaded-jar-file> <class-with-main-method>
 
Gautam Muktsar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:If you're using Maven, check out the Shade Plugin. Like One-JAR it creates one JAR file, but unlike One-JAR it doesn't put the dependencies as JAR files inside a JAR file with a custom class loader, but it just creates a regular JAR file which means you can also use it to create JAR files that you can use in other projects. Also, the JAR files can have multiple classes with main methods that you can use just by specifying the JAR file as the class path: java -cp <shaded-jar-file> <class-with-main-method>


hi i don't know Maven ..i am using NetBeans IDE
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!