You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Rosemarie Hannan (Financial IQ)" <Ro...@fin-soft.co.za> on 2002/01/30 08:19:38 UTC
compiling and creating jars ....
Hi
I am having a problem trying to compile the following, I have set up my
class path in the environment and it still gives me the error - it creates
the java file, but does not compile and it fails just before I specify the
classname and path. If any one can offer some suggestions I would
appreciate it.
Thanks
<!-- Simple Ant build script to test an Ant installation -->
<project name="TestInstall" default="run" basedir=".">
<target name="init">
<available file="ASimpleHelloObject.java" property="ASimpleHelloObject"/>
</target>
<target name="ASimpleHelloObject" unless="ASimpleHelloObject"
depends="init">
<echo file="ASimpleHelloObject .java">
public class ASimpleHelloObject
{
public static void main(String [] args)
{
System.out.println("ASimpleHelloObject.main was called");
}
}
</echo>
<echo message="Wrote ASimpleHelloObject.java"/>
</target>
<target name="compile" depends="ASimpleHelloObject">
<javac destdir="." srcdir="." debug="on" classpath="c:\">
<include name="ASimpleHelloObject.java"/>
</javac>
<echo message="in the compile block after the destdir"/>
</target>
<target name="run" depends="compile">
<echo message="Before the classpath"/>
<java classname="ASimpleHelloObject" classpath="."/>
<echo message="Ant appears to be successfully installed"/>
</target>
</project>
****************************************************
Errors I am getting:
I even commented the one line of code - line 31, and the did the build, this
build went all the way through. Please help me to find out what I have done
incorrectly.
****************************************************
C:\>ant -verbose
Ant version 1.4.1 compiled on October 11 2001
Buildfile: build.xml
Detected Java version: 1.3 in: C:\jdk1.3.1_01\jre
Detected OS: Windows 2000
parsing buildfile C:\build.xml with URI = file:C:/build.xml
Project base dir set to: C:\
Build sequence for target `run' is [init, ASimpleHelloObject, compile, run]
Complete build sequence is [init, ASimpleHelloObject, compile, run]
init:
[available] Unable to find C:\ASimpleHelloObject.java to set property
ASimpleHelloObje
ct
ASimpleHelloObject:
[echo] Wrote ASimpleHelloObject.java
compile:
[echo] in the compile block after the destdir
run:
[echo] Before the classpath
[java] Running in same VM ASimpleHelloObject
BUILD FAILED
C:\build.xml:31: Could not find ASimpleHelloObject. Make sure you have it in
your clas
spath
at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:128)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:305)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:127)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:88)
at org.apache.tools.ant.Task.perform(Task.java:217)
at org.apache.tools.ant.Target.execute(Target.java:184)
at org.apache.tools.ant.Target.performTasks(Target.java:202)
at org.apache.tools.ant.Project.executeTarget(Project.java:601)
at org.apache.tools.ant.Project.executeTargets(Project.java:560)
at org.apache.tools.ant.Main.runBuild(Main.java:454)
at org.apache.tools.ant.Main.start(Main.java:153)
at org.apache.tools.ant.Main.main(Main.java:176)
Total time: 2 seconds
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: compiling and creating jars ....
Posted by Stefan Bodewig <bo...@apache.org>.
I took your build file, removed the classpath attribute from javac
(you don't need it, but it won't do any harm), and removed the space
from the filename in the echo task:
Buildfile: rose.xml
init:
ASimpleHelloObject:
[echo] Wrote ASimpleHelloObject.java
compile:
[javac] Compiling 1 source file to /tmp
[echo] in the compile block after the destdir
run:
[echo] Before the classpath
[java] ASimpleHelloObject.main was called
[echo] Ant appears to be successfully installed
BUILD SUCCESSFUL
Total time: 2 seconds
In the example you've posted, <javac> won't compile anything as the
name of your java file doesn't match your include pattern. After
removing the space it should work.
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: compiling and creating jars ....
Posted by Adam Murdoch <ad...@yahoo.com>.
> -----Original Message-----
> From: Rosemarie Hannan (Financial IQ) [mailto:RosemarieH@fin-soft.co.za]
> Sent: Wednesday, 30 January 2002 5:20 PM
> To: ant-dev@jakarta.apache.org; ant-user@jakarta.apache.org
> Subject: compiling and creating jars ....
> Importance: High
>
>
> Hi
>
> I am having a problem trying to compile the following, I have set up my
> class path in the environment and it still gives me the error - it creates
> the java file, but does not compile and it fails just before I specify the
> classname and path. If any one can offer some suggestions I would
> appreciate it.
> Thanks
>
>
> <!-- Simple Ant build script to test an Ant installation -->
> <project name="TestInstall" default="run" basedir=".">
>
> <target name="init">
> <available file="ASimpleHelloObject.java" property="ASimpleHelloObject"/>
> </target>
>
> <target name="ASimpleHelloObject" unless="ASimpleHelloObject"
> depends="init">
> <echo file="ASimpleHelloObject .java">
^^^
There's a space in the file name.
> public class ASimpleHelloObject
> {
> public static void main(String [] args)
> {
> System.out.println("ASimpleHelloObject.main was called");
> }
> }
> </echo>
> <echo message="Wrote ASimpleHelloObject.java"/>
> </target>
>
> <target name="compile" depends="ASimpleHelloObject">
> <javac destdir="." srcdir="." debug="on" classpath="c:\">
>
> <include name="ASimpleHelloObject.java"/>
> </javac>
> <echo message="in the compile block after the destdir"/>
> </target>
>
> <target name="run" depends="compile">
> <echo message="Before the classpath"/>
> <java classname="ASimpleHelloObject" classpath="."/>
> <echo message="Ant appears to be successfully installed"/>
> </target>
>
> </project>
> ****************************************************
> Errors I am getting:
>
> I even commented the one line of code - line 31, and the did the
> build, this
> build went all the way through. Please help me to find out what
> I have done
> incorrectly.
>
> ****************************************************
>
> C:\>ant -verbose
> Ant version 1.4.1 compiled on October 11 2001
> Buildfile: build.xml
> Detected Java version: 1.3 in: C:\jdk1.3.1_01\jre
> Detected OS: Windows 2000
> parsing buildfile C:\build.xml with URI = file:C:/build.xml
> Project base dir set to: C:\
> Build sequence for target `run' is [init, ASimpleHelloObject,
> compile, run]
> Complete build sequence is [init, ASimpleHelloObject, compile, run]
>
> init:
> [available] Unable to find C:\ASimpleHelloObject.java to set property
> ASimpleHelloObje
> ct
>
> ASimpleHelloObject:
> [echo] Wrote ASimpleHelloObject.java
>
> compile:
> [echo] in the compile block after the destdir
>
> run:
> [echo] Before the classpath
> [java] Running in same VM ASimpleHelloObject
>
> BUILD FAILED
>
> C:\build.xml:31: Could not find ASimpleHelloObject. Make sure you
> have it in
> your clas
> spath
> at
> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:128)
> at org.apache.tools.ant.taskdefs.Java.run(Java.java:305)
> at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:127)
> at org.apache.tools.ant.taskdefs.Java.execute(Java.java:88)
> at org.apache.tools.ant.Task.perform(Task.java:217)
> at org.apache.tools.ant.Target.execute(Target.java:184)
> at org.apache.tools.ant.Target.performTasks(Target.java:202)
> at org.apache.tools.ant.Project.executeTarget(Project.java:601)
> at org.apache.tools.ant.Project.executeTargets(Project.java:560)
> at org.apache.tools.ant.Main.runBuild(Main.java:454)
> at org.apache.tools.ant.Main.start(Main.java:153)
> at org.apache.tools.ant.Main.main(Main.java:176)
>
> Total time: 2 seconds
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>