Reputation: 229
I have a project in Java I am running that uses an external JAR file.
In Eclipse I added the JAR file to the class build path and everything working fine.
But my question is: how can I add it to my project after I created the executable JAR (myPtog.jar) and I am running "ant" in cmd but the external jar file is not found?
This is my build.xml:
<project name="" default="dist" basedir=".">
<description>
Ant
</description>
<!-- Set global properties for this build. -->
<property name="src" location="src"/>
<property name="build" location="target"/>
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init" description="compile the source ">
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<jar jarfile="TPCServer.jar" basedir="${build}">
<manifest>
<attribute name="Main-Class" value="Main1"/>
</manifest>
</jar>
</target>
<target name="clean" description="clean up">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
Upvotes: 0
Views: 190
Reputation: 62769
Maven may do the trick for you. It will auto-configure your project for the most part and give you a simple command line for building a target JAR.
Upvotes: 0
Reputation: 819
In Eclipse, on Project Explorer view, right click your project, than Export...
-> Java
-> Runnable JAR File
. This will re-package all your libs (jars) with your project. Watch out for license permission for re-packaging.
Upvotes: 2
Reputation: 21022
You need to set CLASSPATH appropriately to contain the path of the executable jar as well as the external jars.
Upvotes: 0