1

I am using Eclipse.

I wrote a little Java Gui Tool that depends on the jnetpcap libary which is included in my eclipse project. On my disk the library is placed in a differenct directory than the project.

I want to build a jar (export-> jar) to have it run on other computers, but I did not find out how to "include" the jar file.

I don't mind if it's merged into one file or the library is shipped separately. I just don't know what to configure and where, to have a complete build of that dependency.

oers
  • 18,436
  • 13
  • 66
  • 75
Stefan
  • 2,603
  • 2
  • 33
  • 62
  • What are you using to build the jar? Ant, Maven or manually? – BeRecursive Apr 27 '12 at 08:49
  • I am just using "export -> jar" and add the main-class to the manifest in eclipse gui. – Stefan Apr 27 '12 at 08:54
  • Take a look here: http://stackoverflow.com/questions/6378808/uberjar-through-eclipse and here: http://stackoverflow.com/questions/1832853/is-it-possible-to-create-an-uber-jar-containing-the-project-classes-and-the-pr – BeRecursive Apr 27 '12 at 09:00

2 Answers2

2

There's no out-of the box way to do this, but there are tools that provide jar dependency inclusion.

Jarjar and one-jar come to mind. Both provide ant tasks and the latter has a maven plugin.

If you're using eclipse, when creating executable jar the dependencies get included automatically AFAIK.

soulcheck
  • 36,297
  • 6
  • 91
  • 90
2

I would strongly recommend that you look at build tools like Ant or Maven. They are defacto standard for Java projects and will help you to achieve such tasks.

Look at this link: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

It will basically take 5 minutes of your time to understand the basic principles of Maven and perhaps 30 more to know how to use a plugin to to exactly what you want. If I had known five years ago about Maven it would literally saved weeks of my time.

iuiz
  • 957
  • 1
  • 10
  • 23