Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
| Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 6th, 2007, 06:27 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default about the usage of ant

i used ant(vertion 1.7) and eclipse.
if i do not use the main target,the eclipse display that
BUILD FAILED
Target `main' does not exist in this project.
so every build.xml with Target `main' will be ok.
i found some book code in build.xml without Target `main' also can run. so can anybody tell me about this problem ? thankyou!!!:D

  #2 (permalink)  
Old June 8th, 2007, 01:18 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

HI,

You need to mention the default target in the project tag of your build script so that when you try to run the ant script it'll take the target mentioned in the default attribute and try to run it.
Code:
<project name="B2G" default="build" basedir=".">
If you haven't mentioned this attribute you have to use
 ant [target name]
kind of syntax to run the script.
This applies to any editor you are using or you execute from command prompt.
In eclipse you can configure which target you want to execute in the build script without specifying the default attribute using external tools option in the run menu.

Hope its helpful.

Regards,
Rakesh
  #3 (permalink)  
Old June 8th, 2007, 07:11 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi thank you for this message .
but still does work!
this is my build.xml code
<?xml version="1.0" ?>
<project default="main">
    <target name="main" depends="compile, compress" description="Main target">
        <echo>
            Building the .jar file.
        </echo>
    </target>

    <target name="compile" description="Compilation target">
        <javac srcdir="src/xptoolkit/model"/>
    </target>

  <target name="compress" description="Compression target">
        <jar jarfile="Project.jar" basedir="src/xptoolkit/model" includes="*.class" />
  </target>
</project>
the result is
compile:
    [javac] Compiling 1 source file
compress:
      [jar] Building jar: C:\Documents and Settings\Administrator.WANGPAN\workspace\antexampl e\Project.jar
main:
     [echo] Building the .jar file.
compile:
compress:
BUILD SUCCESSFUL
Total time: 1 second
that is right !!!but if i change the build.xml code which come from some book
<?xml version="1.0" ?>
<project name="hello" default="compile">

    <target name="prepare">
            <mkdir dir="/tmp/classes"/>
      </target>



    <target name="compile" depends="prepare">
        <javac srcdir="./src" destdire="/tmp/classes"/>
    </target>


</project>
the result is that
BUILD FAILED
Target `main' does not exist in this project.

Total time: 90 milliseconds




  #4 (permalink)  
Old June 8th, 2007, 07:17 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

so i find the result need the code have target "main ", "compress" or else the result failed.
and the result do not display the target "clean", "package".
i do not know why ?

  #5 (permalink)  
Old June 8th, 2007, 07:51 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
Try removing the saved configurations in eclipse and then try executing the ant script freshly.
Go to the Run->External Tools->External Tools
In this window you can see the list of saved configurations under Ant build node in the left panel. Right click on saved items and click delete.
Once you delete all the saved list then try executing the ant script freshly.

Regards,
Rakesh
  #6 (permalink)  
Old June 12th, 2007, 06:57 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you indeed Rakesh!
when i ran build.xml in the project inpackage explorer,the problem above happen.
when i ran build.xml in the ant panel, there is no problem!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant reload guacamole82 BOOK: Beginning JavaServer Pages 0 July 18th, 2005 07:01 PM
Building Ant jameshoty BOOK: Professional Apache Tomcat 0 January 23rd, 2005 03:54 AM
NetBeans and WebServices/ANT sakalou J2EE 0 February 3rd, 2004 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.