在Eclipse中,有一个选项Export - > JAR文件。然后我们选择想要导出到输出jar的理想类。
我们怎么能在IntelliJ中做到这一点?
答案 0 :(得分:2)
我不知道你是否需要这个答案,但今天我遇到了同样的问题,我想出了如何解决它。 请按照以下步骤操作:
希望这有助于您和所有遇到此问题的人。 我整天都在浪费尝试使用FatJar在Eclipse上生成jar文件而我无法生成它。
答案 1 :(得分:0)
您可以使用Ant来做到这一点。
<?xml version="1.0" encoding="utf-8"?>
<project name="CustomJar" default="dist" basedir=".">
<description>
Package clases selected package to jar.
</description>
<!-- set global properties for this build. **** The paths are relative to the ant file location *** -->
<property name="src" location="../src/main/java/com/dto/myclasespackage"/>
<property name="build" location="../build"/>
<property name="dist" location="../dist/custom_jar"/>
<property name="version" value="1.0"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory defined above -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init" description="compile the source">
<!-- Compile java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<buildnumber/>
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyApplication-${version}.${build.number}.jar -->
<jar destfile="${dist}/lib/desglose-reports-beans-${version}.${build.number}.jar" basedir="${build}"/>
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directories -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>