Answer the question
In order to leave comments, you need to log in
How to shove the library along with the program itself?
Hello, I am writing a program in NetBeans IDE. The program works with MySQL, and therefore I have attached a library to the project. When assembling the project, in the place with the jar file of my program, the lib folder appears in which all my libraries that I used in the project are located.
But is it possible to somehow assemble the project so that just one jar archive appears in which all the libraries and my program will be located?
Thank you very much in advance!
Answer the question
In order to leave comments, you need to log in
Use maven
If you want to build an executable jar file with dependencies included, I use the maven-assembly-plugin:
<packaging>jar</packaging>
....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>ru.toster.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question