Java - Using Eclipse to produce executable jar
Refer to Simplifying your deployment for other options.
Executable jar has the following limitation:
- The customer's machine may not have appropriate JRE installed (consider packaging and distributing our software as a .exe file or whichever appropriate for our customers)
To use Eclipse to package our application which may involve multiple jar files / class files into a single executable jar, use the following in our build.xml:
<project name="svntool" default="deploy" basedir=".">
<!-- set global properties for this build -->
<property file="build.properties"/>
<property name="src" value="../src" />
<property name="bin" value="../bin" />
<property name="dist" value="../.." />
<path id="project.classpath">
<fileset dir="C:\parsers\commons" casesensitive="no">
<include name="commons-lang-2.4.jar"/>
</fileset>
<fileset dir="C:\parsers\svnkit-1.7.4-v1\lib" casesensitive="no">
<include name="svnkit-cli-1.7.4-v1.jar"/>
<include name="svnkit-1.7.4-v1.jar"/>
</fileset>
</path>
<target name="init">
<!-- Create the dist directory structure used by compile and copy the deployment descriptors into it-->
<tstamp>
<format property="time_stamp" pattern="MM-dd-yyyy-hh-mm-aa"/>
</tstamp>
<mkdir dir="${bin}"/>
</target>
<target name="clean">
<!-- Sometimes you can clean with deleting the module file but it is best dealt on an as needed basis -->
<delete dir="${bin}"/>
</target>
<target name="compile" depends="init">
<!-- Right Now, Fixing Target to 1.2 as Production is on 5.1 -->
<javac optimize="yes" debug="yes" srcdir="${src}" nowarn="on" destdir="${bin}">
<classpath refid="project.classpath" />
</javac>
</target>
<target name="deploy" depends="compile">
<!-- create the executable jars -->
<!-- Start of SVNTool -->
<delete file="${dist}/BackgroundProcesses.jar"/>
<delete dir="${dist}/empty"/>
<mkdir dir="${dist}/empty"/>
<jar destfile="${dist}/BackgroundProcesses.jar" basedir="${dist}/empty">
<zipgroupfileset dir="C:\parsers\log4j" includes="log4j-1.2.14.jar"/>
<zipgroupfileset dir="C:\parsers\svnkit-1.7.4-v1\lib" includes="svnkit-cli-1.7.4-v1.jar"/>
<zipgroupfileset dir="C:\parsers\svnkit-1.7.4-v1\lib" includes="svnkit-1.7.4-v1.jar"/>
<zipgroupfileset dir="C:\parsers\commons" includes="commons-lang-2.4.jar"/>
<fileset dir="${bin}" includes="*.class"/>
</jar>
<sleep seconds="1"/>
<jar destfile="${dist}/svntool.jar" basedir="${dist}/empty">
<manifest>
<attribute name="Main-Class" value="SVNTool"/>
</manifest>
<zipfileset excludes="**/META-INF/**" src="${dist}/BackgroundProcesses.jar"/>
</jar>
<delete file="${dist}/BackgroundProcesses.jar"/>
<delete dir="${dist}/empty"/>
</target>
</project>
Refer to Simplifying your deployment for other options.
page revision: 5, last edited: 25 May 2012 23:40