将.jar库与我的.jar相结合 [英] Combinate .jar library with my .jar

查看:64
本文介绍了将.jar库与我的.jar相结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javaFX中有一个项目,并且我正在使用ControllerFX库,.jar文件中的问题是必须将库的.jar文件保存在我的.jar项目中. 有没有办法使用intellij idea将库的.jar与项目的.jar组合在一起? Maven在这种情况下有帮助吗? (我不知道行家到底能做什么) 谢谢答案

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

推荐答案

与项目一起使用的jar称为依赖jars .您可以在创建自己的项目的jar时捆绑它们.

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方法

Intellij Approach

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

下一个转到

Build 
   | 
   Build artifacts --> choose your artifact

Maven方法

Maven Approach

  1. 创建一个Maven项目,并将包装保留为 jar .
  2. 添加可执行jar插件,并添加Main class详细信息和从属jar
  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>

这篇关于将.jar库与我的.jar相结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆