Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / February 2004

Tip: Looking for answers? Try searching our database.

Beginer question in Ant script

Thread view: 
Madhavi - 05 Feb 2004 00:20 GMT
Hi,

This is my first Ant script.
I have a class with one line system.out.println in main method.
Using following Ant script I am getiing this exception.
It is printing my message as I expect but there is IllegalArgumentException
Why do I get this exception.
I tried putting default constructor with no arguments then also same issue.
Please advice.

Thanks,
Madhavi Surisetty.

=========Output=====================================
init:
   [mkdir] Created dir: C:\new\dist
   [mkdir] Created dir: C:\new\dist\classes

compile:
   [javac] Compiling 1 source file to C:\new\dist\classes

run:
    [java] initializeClass: class ClassA
    [java] initializeClass: class ClassA  throws: java.lang.IllegalArgumentExce
ption: wrong number of arguments
    [java] This is ClassA

BUILD SUCCESSFUL
Total time: 3 seconds
C:\new>
==========End Output=================================

=====Ant Script=======
<project name="antProject" default="compile">
    <property name="dist" value="dist"/>
    <property name="build" value="${dist}/classes"/>
    <target name="init">
        <mkdir dir="${dist}"/>
        <mkdir dir="${build}"/>
    </target>

    <target name="compile" depends="init">
        <javac srcdir="src" destdir="${build}"/>
    </target>

    <target name="run" depends="compile">
        <java classname="ClassA" debug>
            <classpath path="${build}"/>
        </java>
    </target>
</project>
===End Ant Script========

====ClassA ============
public class ClassA
{
    public ClassA()
    {
    }
    public static void main(String a[])
    {
        System.out.println("This is ClassA");
    }
}
======End ClassA============
Ville Oikarinen - 17 Feb 2004 07:04 GMT
> I tried putting default constructor with no arguments then also same issue.
> Please advice.

Constructors have nothing to do with this. Your "ClassA" class will never get
instantiated. Instead the static main method will be called.

> <target name="run" depends="compile">
> <java classname="ClassA" debug>
> <classpath path="${build}"/>
> </java>

What is this "debug" here. According to the ant docs the java target has no such
attribute. I don't know if it's even legal XML to write attributes without
values. Anyway, try removing it.

However, what I don't understand is why ant doesn't complain about this right in
the beginning when validating the build.xml file.

Ville Oikarinen


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.