aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem while installing ANT!! Help me here!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Problem while installing ANT!! Help me here!!" Watch "Problem while installing ANT!! Help me here!!" New topic
Author

Problem while installing ANT!! Help me here!!

jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Hi all,
I downloaded the apache-ant-1.5.2-bin.zip version and extracted to c:\apache-ant-1.5.2 folder and set ANT_HOME, JAVA_HOME and Path environment variables.
JDK I am using is, j2sdk1.4.1_01. I am just wanted to run the examples from "Oreilly Ant - The Definitive Guide". I downloaded the examples from oreilly website and tried to run the build scripts,
example,
c:\Anttutorial\chapter1\>ant
chapter1 directory has required build.xml file.
I am getting Java Usage option as below..
C:\ANTTUTORIAL\chapter1>ant
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp -classpath <directories and zip/jar files separated by ;>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
C:\ANTTUTORIAL\chapter1>
What might be the problem/reason?? I am very desperate..
Thanks,
Jyothi


jyothi
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

When you execute ant on Windows command prompt, you are actually running ant.bat from the ANT_HOME/bin directory. From bash or other Unix-like shell, it is just ant in the same directory. That script sets some things up, but mostly just runs a java program. The main line is something like:
$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" "$ANT_OPTS"org.apache.tools.ant.Main
The JAVACMD, LOCALCLASSPATH, and ANT_OPTS are set up by the script (but based on JAVA_HOME and CLASSPATH from your environment.) ANT_HOME is taken from your environment.
I do have a point here. I think it's the execution of ant itself that is failing. Maybe you can doublecheck your variables. Especially on Windows, you have to be sure they are set up before you open the command window. You can check them before you execute ant, by typing:
(windows)
set ANT_HOME
set JAVA_HOME
(bash)
echo $ANT_HOME
echo $JAVA_HOME
(etc.) If all that looks good, you can put echo statements into the script itself. There's got to be something simple wrong.
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Hi Greg,
Thanks for your response. I also think there might be a simple mistake, but I am not able find that. Looks like everything is right.
When I am trying to run this command from command prompt,
c:\>java -Dant.home=c:\apache-ant-1.5.2 org.apache.tools.ant.Main
I am getting following error,
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/Main
My OS is Windows 2000. And I set the properties as below,
ANT_HOME=c:\apache-ant-1.5.2
JAVA_HOME=c:\j2sdk1.4.1_01
Path=c:\apache-ant-1.5.2\bin\;%path%;
What should I do here??
Thanks in advance,
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

Well, in the case of running the java command yourself, you have to set your classpath to include at least ant.jar, and preferably all jars, from the ANT_HOME/lib directory. The ant (or ant.bat) should do that for you automatically if the ANT_HOME variable is set.
Given that you're in Windows, I recommend editing ANT_HOME/bin/ant.bat and removing the first line (@echo off). That way you should see what it's doing as it does it. Make a backup of that file before you start editing it, just in case.
narasimharao konjeti
Ranch Hand

Joined: Apr 26, 2003
Posts: 130
ur problem requires these classpath and path setting.
set JAVA_HOME env variable as system environment variable. then set ur ANT_HOME env variable value.
ex.
JAVA_HOME=C:\JDK1.4(SHOLD BE SYSTEM ENVIRONMENT VARIABLE)
ANT_HOME=C:\ANT
then set path for jdk and ant and say
build. it will build ur required .war or .ear files
cheers
nr konjeti


"Unwise to sweat petty stuff, wise to pet sweaty stuff."
narasimharao konjeti
Ranch Hand

Joined: Apr 26, 2003
Posts: 130
and apache home set as
CATALINA_HOME=C:\APACHE......
AND LET ME UR OPERATING SYSTEM.
AND SET CLASSPATH IN classpath.bat fine in apache
ok
cheers
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Thanks to both of you...By the way my problem solved. I included the ant.jar in my classpath..
now it is working fine..
Thanks a lot,
Al Larson
Greenhorn

Joined: May 10, 2003
Posts: 1
Hi All:
I had the same problem, and what was causing it in my case was how I set my ANT_HOME. I had it set to:
E:\apache-ant-1.5.3-1\
I took Greg Charles' advice and took out the @echo off at the start of the ant.bat file. When I looked at the output I saw things like 'E:\>if ""E:\apache-ant-1.5.3-1\\lib\xml-apis.jar"" == """" goto gotAllArgs'.
I took out the last slash and set ANT_HOME to:
E:\apache-ant-1.5.3-1
and it finally worked. Thanks a lot for the help!
Al
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while installing ANT!! Help me here!!