allstraws
allstraws

Reputation: 129

How to make a .jar executable for source code tree using ANT

I am a beginner programmer, so please co-operate if I am asking very basic questions. Actually I want to add some additional features in an open-source software.

So I made necessary changes to one of the ".java" file that came with the source code and now I want to make a ".jar" executable for it. So I came to know that I must use ANT for it to automate this process. But when I run the ANT script on "build.xml" provided with the source code, I get the same compilation errors "symbol not found.." many times and the build failed.

I asked this question yesterday here and I get to know that this is because of CLASSPATH problems. Now I researched and get to know how to handle the CLASSPATH with JAVAC on command line but I do not know how to handle it with ANT. So please guide me how should I proceed, I actually want to compile the entire Source Code Tree and make a ".jar" executable for it.

Upvotes: 1

Views: 81

Answers (2)

Anup
Anup

Reputation: 316

jar destfile="D:/SushiBuilt/SushiAutomation.jar" /// whatever drive you want its a demo

fileset dir="C:/Users/adiuser1/Desktop/Anupam/sushiAutomationCounter4/sushiAutomationCounter4/bin"

Take the bin path of the your project.

And right click on the build.xml-> Run as Ant Build.

Upvotes: 4

Prashant
Prashant

Reputation: 2614

You can write code in your ANT script like below and check once..

<path id="classpathVariable">
        <include name="*.jar"/>
    <fileset dir="lib">
        <include name="**/*.jar"/>
    </fileset>      
</path>
<target name="compile">
    <delete dir="BIN"  failonerror="false"/>
    <mkdir dir="BIN" />
    <javac executable="javac" encoding="utf-8"
        srcdir="src" destdir="BIN" debug="on" 
        debuglevel="lines,source,var" memoryInitialSize="500m"
        memoryMaximumSize="1024m" > <classpath refid="classpathVariable" /> </javac>
</target>

in this case you can create one variable that will be used as class path and use javac command. BIN folder will have all the class files.

Upvotes: 0

Related Questions