Combinate .jar library with my .jar

不打扰是莪最后的温柔 提交于 2020-01-07 08:31:54

问题


I have a project in javaFX and I'm using ControllerFX Library , the problem here in the .jar file it's necessery to keep .jar file of the library with my .jar project. is there a way to combine .jar of library with .jar of project using intellij idea ? does Maven help in this situation? (I don't know exactly what maven can do) thanks for answers


回答1:


The jars that you use with your project are called as the dependent jars. You can bundle them while creating a jar of your own project.

Intellij Approach

File
  |
  Project Structure 
     | 
     Artifacts
           |
           create new artifact choose --> jar --> From modules with dependencies.

Next goto

Build 
   | 
   Build artifacts --> choose your artifact

Maven Approach

  1. Create a Maven project and keep the packaging as jar.
  2. Add the executable jar plugin and add your Main class details and your dependent jars
<build>
  <plugins>
     <plugin>
       <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
           <descriptorRefs>
             <descriptorRef>jar-with-dependencies</descriptorRef>
           </descriptorRefs>
           <archive>
             <manifest>
               <mainClass>fully.qualified.MainClass</mainClass>
             </manifest>
           </archive>
         </configuration>
      </plugin>
   </plugins>
</build>


来源:https://stackoverflow.com/questions/24264811/combinate-jar-library-with-my-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!