More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Check Properties 
 

In this section, you will learn how to check properties using environment variable whether is set or not.

 

Check Properties

                         

This example illustrates how to check properties using environment variable whether it is set or not. In this code, there are three properties; the first two are used to define source directory and destination directory. The source directory is 'src' and the destination directory is 'build'. The element <property environment="env"> is a path of jar file dependent on environment variables, and these are available only if you use <property environment="env"> before you import the property file. The following example shows how to check whether TOMCAT_HOME environment variable is set or not. If TOMCAT_HOME environment variable is set, then the output will display build successful... as given below.


build.xml

 

<project name="Check Properties" default="compile" basedir=".">

  <property name="dir.src" value="src"/>
  <property name="dir.build" value="build"/>
  <property environment="env"/>

  <target name="check">
    <fail unless="env.TOMCAT_HOME">TOMCAT_HOME class path must be set</fail>    
  </target>

  <target name="clean" depends="check">
    <delete dir="${dir.build}"/>
  </target>

  <target name="prepare" depends="clean">
    <mkdir dir="${dir.build}"/>
  </target>

  <target name="compile" depends="prepare" >
    <echo>Compile code...</echo>
  </target>

</project>


Output:


But if TOMCAT_HOME environment variable is not set, then the following error message will be displayed.


Download Source Code

                         

» View all related tutorials
Related Tags: sql c database xml file url data ui build property user sed password word driver vi name using this element

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.