0

I'm using IntelliJ without a build tool for a project, I build it as a jar.

Now I'm using the iText library for PDF(s), if I put all the iText jars into a folder and add it in IntelliJ, I can use the iText functions and if the program works, I add iText as dependency and set it in Build Artifacts for the Jar, but if I build it, it just copies the compiled iText jar into my jar, so the program doesn't work.

How do I include the Library correctly in the jar, without a build tool?

Ram
  • 3,092
  • 10
  • 40
  • 56
dav20011
  • 71
  • 3
  • 14
  • When you say "without a build tool", do you mean something like ant? – Amir Afghani Jun 17 '15 at 17:48
  • Yes, I just build it with the default compiler. – dav20011 Jun 17 '15 at 17:51
  • How do you test your jar? What is your execution command? And could you clear that what do you mean by "copying the compiled iText jar to my jar". When you open your jar with a package manager (like Winrar) you see iText.jar in your jar or you see iText's packages in your jar? – bhdrkn Jun 17 '15 at 17:53
  • I run it with IntelliJ Run, Application, and then just the Main class, and in before launch it does make. I have a itextpdf (compiled), and a source edition, if I open my jar I see my programm with it's packages and a copy of the compiled itextpdf-5.5.6 jar. – dav20011 Jun 17 '15 at 17:59
  • Could this solve your problem: http://stackoverflow.com/questions/20952713/wrong-manifest-mf-in-intellij-idea-created-jar – lilott8 Jun 17 '15 at 18:55
  • Also, please add more than "the program doesn't work" to descriptions. Does it throw an exception (`ClassNotFoundException`)? Does it run but doesn't spit out the correct output? I think you get the point. – lilott8 Jun 17 '15 at 18:56

1 Answers1

1

Go to Project Structure (Ctrl + Shift + Alt + S) > Artifacts > + > Jar > From Modules with dependencies

Select your module and the main class. Select Extract to the target JAR if you want to bundle all your libraries into one file.

Close the dialog and check (or change) the output folder - that's where your JAR will be created.

Now go to Build > Build Artifacts and select the artifact you just created.

Reference

Darek Kay
  • 15,827
  • 7
  • 64
  • 61