【发布时间】:2014-03-24 00:04:10
【问题描述】:
在 Eclipse 中,有一个选项 Export -> JAR File。然后我们选择想要导出到输出jar的类。
我们如何在 IntelliJ 中做到这一点?
【问题讨论】:
-
我遇到了同样的问题。我制作了一个没有主类的 solr 模块。我找不到在 inteliji 中导出它的方法。显示的所有方法都适用于可执行的 jar 文件。
标签: jar intellij-idea
在 Eclipse 中,有一个选项 Export -> JAR File。然后我们选择想要导出到输出jar的类。
我们如何在 IntelliJ 中做到这一点?
【问题讨论】:
标签: jar intellij-idea
我不知道你是否需要这个答案,但我今天遇到了同样的问题,我想出了如何解决它。 请按照以下步骤操作:
希望这对您和遇到此问题的每个人都有帮助。 我浪费了一整天的时间尝试使用 FatJar 在 Eclipse 上生成 jar 文件,但我无法生成它。
【讨论】:
您可以使用 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>
【讨论】: