|
ANT |
|
Now here is the code of simple build.xml file
which compiles a java file present in src
directory and places compiled class file in
build / src directory.
<?xml version=”1.0"?>
<!— Build file for our first application —>
<project name=”Ant test project”
default=”build” basedir=”.”>
<target name=”build” >
<javac srcdir=”src” destdir=”build/src”
debug=”true” includes=”**/*.java” />
</target>
</project>
First line of the build.xml file represents the
document type declaration. Next line is
comment entry. Third line is the project tag.
Each build file contains one project tag and all
the instruction are written in the project tag.
The project tag:
<action name=”HelloWorld”
class=”net.javajazzup.Struts2HelloWorld”> <result>/pages/HelloWorld.jsp</result> </action>
requires three attributes namely name, default and basedir.
Here is the description of the attributes:
name |
Represents the name of the
project. |
default |
Name of the default target to use
when no target is supplied. |
basedir |
Name of the base directory from
which all path calculations are
done. |
All the attributes are required.
One project may contain one or more targets.
In this example there is only one target.
Which uses task javac to compile the java
files.
<target name=”build” >
<javac srcdir=”src” destdir=”build/src”
debug=”true” includes=”**/*.java”/>
</target>
Here is the code of our test.java file, which is
to be compiled by the Ant utility.
class test{
public static void main (String args[])
{
System.out.println(“This is example 1”);
}} |
|
Download the code of this article and unzip it
in c:\. files will be unzipped in anttest
directory. To run the Ant utility to compile the
file go to c:\anttest\example1 and issue
ant command. You will receive the following
out put.
C:\anttest\example1>antBuildfile: build.xml
build:[javac] Compiling 1 source file to
C:\anttest\example1\build\src
BUILD SUCCESSFUL
Total time: 4 seconds
C:\anttest\example1>
Above-mentioned process compiles the file
and places in the build \ src directory.
Now let’s see how to build a web application
and install it on the Jboss 3.2.3 application
server.
After the completion of this article you will be
able to include jsp, html and servlets in the
ear file and deploy on the JBoss 3.2.3
application server. A complete example in this
section will provide a strong foundation for
the further development.
Let’s write one Hello World Servlet and a JSP
file file to retrieve the Hello World Servlet. In
order to deploy components we have to build
.ear file which is the standard format for the
deployment of JEE application.
First of all let’s understand the structure of
.ear and .war files.
Enterprise Archive Contents
Enterprise Archive (.ear) component follows
the standard directory structure defined in
the JEE specification.
Directory Structure of .ear archive
/
.war and .jar files
META-INF
application.xml
|
|
Dec 2007 | Java Jazz Up |36 |
|
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70 ,
71 ,
72 ,
73 ,
74 ,
75 ,
76 ,
77 ,
78 ,
79 ,
80 ,
81 ,
82 , Download PDF |
|
|
|
|
|
|
|
|
|