简体   繁体   中英

Build jar and include library jar

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM