Solved

using ant for compiling java files

Posted on 2004-08-16
4
192 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

932 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

10 Experts available now in Live!

Get 1:1 Help Now