Solved

using ant for compiling java files

Posted on 2004-08-16
4
198 Views
Last Modified: 2012-05-05
i have java files in many packages. Such as
com\pack1\pack2\pack3\ (java files here)
com\pack1\pack2\ (java files here)
com\pack1\ (java files here)
.....
com\a\b\c\(java files here)
com\a\b\(java files here)
..

I have to give an option to the end user to compile the source files(if she ever wants to do so). So I asked this ques in EE that how can i do this without using many javac statments and putting them in a batch file. i was suggested that i should use ant.
Now I have managed to compile the source files using ant and copy other files(such as xml, xsl, jar etc) to the target directory. I do this by  first navigating to the ant folder(which has build.xml file) and writing ant there. It compiles all those java files and puts them in build directory along with other needed files.
What i want to know is how can i make the end user use this. Do i have to tell her to install ant, copy build.xml file there and the source dir and navigate to it and write ant or is there a better way of doing this?
Thanks

0
Comment
Question by:thomas908
  • 2
4 Comments
 
LVL 8

Author Comment

by:thomas908
ID: 11807849
here is my build.xml

<?xml version="1.0"?>

<project name="My" default="compile" basedir=".">
<property name="name" value="My" />
<property name="build" value="${basedir}\build" />
<property name="source" value="${basedir}\source\src" />
<property name="baselib" value="\source" />

<target name="init" >

     <mkdir dir="build" />

</target>

<target name="CopyFiles" depends="init">
    <copy toDir="build">
      <fileset dir="source"
        includes="**/*.*">
        <exclude name="**/*.java"/>
      </fileset>
    </copy>
</target>



<target name="compile" depends="CopyFiles" >
    <javac srcdir="${source}" destdir="${build}">
    </javac>
</target>



</project>
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 125 total points
ID: 11807887
If you bundle all the files together then you can specify default folders for your ant scripts. These folders should be relative to where you install ant otherwise the user would have to use absolute paths and this is not recommended.
0
 
LVL 6

Accepted Solution

by:
expertmb earned 125 total points
ID: 11807894
>>Do i have to tell her to install ant,
yes user has to have ant installed in their system to run the ant.

>>copy build.xml file there and the source dir and navigate to it and write ant or is there a better way of doing this?

copy entire src in zip format. user will extract it, the folder will be created as per your dir structure.
after installing ant she has to run the ant command.

another way is to write the installation document. i feel this is a good option.

mb...
 
0
 
LVL 35

Expert Comment

by:girionis
ID: 11838520
:)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now