Results 1 to 5 of 5
  1. #1
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question Problem in running ant

    Hi Every One,
    I am new to ant.To learn ant,i am following some online tutorials.when i tried to run ant from command prompt i got some errors.Here is my problem..

    I have created a simple directory structure like
    TestAnt
    l
    -->src-->HelloWorld.java
    l
    --> build.xml

    When i tried to run ant from command prompt result was like this

    Java Code:
    E:\WINDOWS\java\TestAnt>ant
    Unable to locate tools.jar. Expected to find it in E:\Program Files\Java\jre1.6.0_05\lib\tools.jar
    Buildfile: build.xml
    
    init:
    
    compile:
        [javac] Compiling 1 source file to E:\WINDOWS\java\TestAnt\build
    
    BUILD FAILED
    E:\WINDOWS\java\TestAnt\build.xml:20: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "E:\Program Files\Java\jre1.6.0_05"
    
    Total time: 0 seconds
    and my environment variable values are
    Java Code:
    path=E:\oraclexe\app\oracle\product\10.2.0\server\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E:\WINDOWS\jdk6\bin;C:\apache-ant-1.7.0-bin\bin;
    
    JAVA_HOME=E:\WINDOWS\jdk6\bin;E:WINDOWS\jdk6
    
    ANT_HOME=C:\apache-ant-1.7.0-bin
    Is there any mistake in my environment variables ?

    My JAVA_HOME value is

    Java Code:
    E:\WINDOWS\jdk6\bin;E:WINDOWS\jdk6
    But when i am running ant i got message like
    Java Code:
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "E:\Program Files\Java\jre1.6.0_05"
    Can any one please tell me what's wrong with this..


    Thank q very much,
    Sireesha.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default

    Instead of JRE you should also have the JDK on your computer. JRE doesn't come with the javac command. Have you install the JDK?

  3. #3
    naresh_m is offline Member
    Join Date
    May 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi sireesha,
    u have to the PATH variable as E:\Program Files\Java\jre1.6.0_05
    and

  4. #4
    naresh_m is offline Member
    Join Date
    May 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi sireesha,
    u have to set the the PATH variable as E:\Program Files\Java\jre1.6.0_05\bin
    in envronment variable and CLASSPATH variable as C:\Program Files\Java\jdk1.5.0_15\lib\tools.jar; ok

  5. #5
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question

    Hi,
    Thank q very much for your replies ,I changed both path and classpath variables .Now this time i got a message like build successful.
    But i am still getting message like Unable to locate tools.jar.
    But this time my java class is compiled so i am happy.But i took this example from a site.So i didn't understand code written in build.xml.My build.xml file is
    Java Code:
    <project name="TestAnt" default="dist" basedir=".">
        <description>
            simple example build file
        </description>
      <!-- set global properties for this build -->
      <property name="src" location="src"/>
      <property name="build" location="build"/>
      <property name="dist"  location="dist"/>
    
      <target name="init">
        <!-- Create the time stamp -->
        <tstamp/>
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
      </target>
    
      <target name="compile" depends="init"
            description="compile the source " >
        <!-- Compile the java code from ${src} into ${build} -->
        <javac srcdir="${src}" destdir="${build}"/>
      </target>
    
      <target name="dist" depends="compile"
            description="generate the distribution" >
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}/lib"/>
    
        <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
      </target>
    
      <target name="clean"
            description="clean up" >
        <!-- Delete the ${build} and ${dist} directory trees -->
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
      </target>
    </project>
    Can any one please explain me what is use of this build.xml and different terms in this file..

    and aslo

    Can any please tell me how to use this build.xml ( or ant) in case of web applications.


    I am really confused with using ant.I read different tutorials but i couldn't understand properly.I need some explanation..Please anybody give me some explanation in this topic...

    Thank q very much,
    sireesha.

Similar Threads

  1. Problem while running web service client
    By krsv36 in forum Other IDEs
    Replies: 0
    Last Post: 05-15-2008, 05:12 PM
  2. jsp running problem
    By bharanikumariyerjava in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-29-2008, 10:48 AM
  3. problem while running java code..
    By Jjava in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 06:33 AM
  4. Running a system
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 06-29-2007, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •