Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using ant for compiling java files

Posted on 2004-08-16
4
Medium Priority
?
227 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

609 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