?
Solved

using ant for compiling java files

Posted on 2004-08-16
4
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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 500 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 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