Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6913923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:16:51+00:00 2026-05-27T09:16:51+00:00

I am trying to package my web application into war file using Ant. When

  • 0

I am trying to package my web application into war file using Ant.

When I build, I am getting the following error:

C:\Documents and Settings\Administrator\workspace\Assignment7\build.xml:67: 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 "C:\Program Files\Java\jre6"

The following is my build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="Generate War" default="install" basedir=".">


    <property name="build.dir" value="build"/>
    <property name="dir.name" value="Assignment7"/>
    <property name="package.name" value="${dir.name}.war"/>

    <property name="content" value="webContent"/>
    <property name="web-inf" value="${content}\WEB-INF"/>
    <property name="meta-inf" value="${content}\META-INF"/>
    <property name="jsp.dir.name" value="${content}"/>

    <property name="lib" value="${web-inf}\lib"/>
    <property name="src" value="src"/>
    <property name="dest.dir" value="target"/>

    <!-- Setting path to the server webapp folder -->

    <property name="webapp.dir" value="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps"/>

    <!--  Using temp folder for convinence -->

    <property name="temp.dir" value="temp"/>
    <property name="temp.dir.web-inf" value="${temp.dir}\WEB-INF"/>
    <property name="temp.dir.meta-inf" value="${temp.dir}\META-INF"/>
    <property name="temp.dir.lib" value="${temp.dir.web-inf}\lib"/>
    <property name="temp.dir.classes" value="${temp.dir.web-inf}\classes"/>
    <!--<property name="temp.dir.classes.dir" value="${temp.dir.classes}\**"/>-->

    <property name="package.file" value="${dest.dir}\${package.name}"/>

    <path id="build.class.path">
        <fileset dir="${lib}">
            <include name="**/*.jar"/>
        </fileset>
    </path>
    <path id="build.class.path1">
        <fileset dir="C:\program files\java\jre6\lib">
            <include name="**/*.jar"/>
        </fileset>

    </path>

    <target name="clean">
        <delete>
            <fileset dir="${dest.dir}" includes="**/*"/>
        </delete>
        <delete dir="${temp.dir}"/>
        <delete dir="${temp.dir.classes}"/>
        <delete dir="${temp.dir.web-inf}"/>
        <delete dir="${temp.dir.meta-inf}"/>
    </target>


    <target name="prepare" depends="clean">
        <mkdir dir="${dest.dir}"/>
        <mkdir dir="${temp.dir}"/>
        <mkdir dir="${temp.dir.web-inf}"/>
        <mkdir dir="${temp.dir.lib}"/>
        <mkdir dir="${temp.dir.classes}"/>
        <mkdir dir="${temp.dir.meta-inf}"/>
    </target>

    <target name="compile" depends="prepare">
        <echo>==="complie"===</echo>
        <javac srcdir="${src}" destdir="${temp.dir.classes}" debug="on">
            <classpath refid="build.class.path"></classpath> 
        </javac>
        <!--<copydir src="${build.dir}\classes" dest="${temp.dir.classes}"/>-->
    </target>

    <target name="package" depends="compile">
        <echo>"PACKAGING THE FILES"</echo>
            <copy file="${meta-inf}\MANIFEST.MF" tofile="${temp.dir.meta-inf}\MANIFEST.MF" overwrite="true"/>
            <copy file="${web-inf}\web.xml" tofile="${temp.dir.web-inf}\web.xml" overwrite="true"/>
            <copy file="${web-inf}\tiles.xml" tofile="${temp.dir.web-inf}\tiles.xml" overwrite="true"/>
            <copy todir="${temp.dir.classes}">
                <fileset dir="${src}">
                    <include  name="**/*.xml"/>
                </fileset>
            </copy>

            <war destfile="${package.file}" webxml="${temp.dir.web-inf}\web.xml" basedir="${temp.dir}">
                <fileset dir="${jsp.dir.name}"/>
                <lib dir="${lib}"></lib>
                <classes dir="${temp.dir.classes}"></classes>
            </war>
    </target>

    <target name="jsps">
            <copy todir="${webapp.dir}\${dir.name}">
                <fileset dir="${content}">
                    <include name="**/*.jsp"/>
                    <include name="**/*.html"/>
                    <include name="**/*.css"/>
                    <include name="**/*.gif"/>
                    <include name="**/*.jpg"/>
                    <include name="**/*.png"/>
                    <include name="**/*.js"/>
                </fileset>
            </copy>
    </target>

    <target name="install" depends="package">
            <copy file="${package.file}" todir="${webapp.dir}" overwrite="true"/>
    </target>

</project>

How can I compile a class file that does not have a main class?

How do I set the class path?

For reference, I am using Eclipse.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:16:51+00:00Added an answer on May 27, 2026 at 9:16 am

    All your ant stuff will work fine except the javac task which needs the tools.jar, located in the /lib directory from the JDK, JRE is not sufficient in that case. Therefore the hint from ant : “Unable to find a javac compiler;…”

    When working with Eclipse the default setting points to your JRE installation.
    So, one of your first steps after starting Eclipse for the first time should be :
    Window > Preferences > Java > Installed JREs and change the settings from JRE to JDK.
    Alternatively use :
    Window > Preferences > Ant > Runtime > Classpath > Global Entries
    and add the tools.jar from your JDK/lib folder

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a sample application using ANT build. But i am
I'm trying to deploy a web service onto WebSphere using a WAR file, which
I'm trying to deploy a web application using MSDeploy, on Team Build in TFS.
I'm trying to package a web application as a runnable JAR file with Maven.
Trying to install pear package and keep getting this strange error. Can you shed
Hi so I am trying to create a deb package for a web application
I am trying to develop a Wicket-based web application using Hibernate at the model
I have downloaded the Layar401.apk file from web and trying to install it into
I am trying automate a login process to my web application using Selenium-Python Client
I'm running into the following issue with a WAR I am generating using Warbler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.