You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ma...@yahoo.com on 2006/10/09 16:37:49 UTC
class path problem
Hi Every Body:
I am facing a probelm compile a java application. My Java application
uses external and internal library.
In other words, let's say i have a package called java.matrix, and I
wrote a package for this project called MathOp,
the layout of my project directory is :
MyProject
MathOp
Addition.java
Multiplication.java
Subtraction.java
Division.java
Operation1
some classes
Operation2
more classes
build.xml
resulting_classes_directory
MANIFEST.1
Now I need to be able to include all or the needed classes from MathOp
into the compilation of Operation1, and put the results in
resulting_classes_directory. I can do this from the command promt using
option of javac and it works fine for exmaple I can do :
javac -classpath /opt/j2sdk/lib/:/path/to/my/project:Operation1 -d
resulting_classes_directory/ Operation1/*.java
When I try to do this with ant, it fails complaining about not finding
the classes in the package MathOp. I dont want to compile the whole
package of MathOp. Please don't suggest this. I want it to be compiled
when the classes that needs it is compiled. Here's what I have in my
build.xml file.
<target name="op1" description="Compiles the Operation 1 and package it">
<javac srcdir="Operation1"
destdir="resulting_classes_directory" includes="**/*.java" >
<classpath>
<pathelement path="Operation1"/>
<pathelement path="."/>
<pathelement path="/path/to/my/project"/>
<pathelement path="/opt/j2sdk/lib/" />
<fileset dir="Operation1">
<include name="**/*.java"/>
</fileset>
</classpath>
</javac>
<jar destfile="Op1.jar" basedir="resulting_classes_directory"
manifest="MANIFEST.1" />
</target>
none of the classes are compiled, "And It Is Important That They Are
Compiled Only When Ant Is Invoked."
Please let me know what I am missing here, or at least what to search
for in google.
Thank you in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: class path problem
Posted by Prashant <pr...@pramati.com>.
Use switch -verbose when running your ant target. This will spit out the
'javac' command ANT is using.
Eg: ant op1 -verbose
Examine how this command is different from the 'javac' command that
works for you.
Hope this helps.
-Prashant
mansour77@yahoo.com wrote:
> Hi Every Body:
> I am facing a probelm compile a java application. My Java application
> uses external and internal library.
> In other words, let's say i have a package called java.matrix, and I
> wrote a package for this project called MathOp,
>
> the layout of my project directory is :
> MyProject
> MathOp
> Addition.java
> Multiplication.java
> Subtraction.java
> Division.java
> Operation1
> some classes
> Operation2
> more classes
> build.xml
> resulting_classes_directory
> MANIFEST.1
>
> Now I need to be able to include all or the needed classes from MathOp
> into the compilation of Operation1, and put the results in
> resulting_classes_directory. I can do this from the command promt
> using option of javac and it works fine for exmaple I can do :
> javac -classpath /opt/j2sdk/lib/:/path/to/my/project:Operation1 -d
> resulting_classes_directory/ Operation1/*.java
> When I try to do this with ant, it fails complaining about not finding
> the classes in the package MathOp. I dont want to compile the whole
> package of MathOp. Please don't suggest this. I want it to be compiled
> when the classes that needs it is compiled. Here's what I have in my
> build.xml file.
>
> <target name="op1" description="Compiles the Operation 1 and
> package it">
> <javac srcdir="Operation1"
> destdir="resulting_classes_directory" includes="**/*.java" >
> <classpath>
> <pathelement path="Operation1"/>
> <pathelement path="."/>
> <pathelement path="/path/to/my/project"/>
> <pathelement path="/opt/j2sdk/lib/" />
> <fileset dir="Operation1">
> <include name="**/*.java"/>
> </fileset>
> </classpath>
> </javac>
> <jar destfile="Op1.jar" basedir="resulting_classes_directory"
> manifest="MANIFEST.1" />
> </target>
>
> none of the classes are compiled, "And It Is Important That They Are
> Compiled Only When Ant Is Invoked."
> Please let me know what I am missing here, or at least what to search
> for in google.
> Thank you in advance.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: class path problem
Posted by ma...@yahoo.com.
Yes, it worked as Scot suggested, It was the matter of using the
sourcepath. Here's the desciption fro the website:
*=================================================================================
sourcepath*
The *sourcepath* to use; defaults to the value of the srcdir attribute
(or nested |<src>| elements). To suppress the *sourcepath* switch, use
|*sourcepath*=""|.
*=================================================================================
I added **sourcepath="." and all went well. Thank you all.
**
*
Scot P. Floess wrote:
> When you execute your ant script, what directory are you "standing"
> in? I see you give a "relative" srcdir of Operation1. Are you
> standing in the directory that Operation1 lives? You may also need to
> use sourcepath attribute.
>
> mansour77@yahoo.com wrote:
>
>> Hi Every Body:
>> I am facing a probelm compile a java application. My Java application
>> uses external and internal library.
>> In other words, let's say i have a package called java.matrix, and
>> I wrote a package for this project called MathOp,
>>
>> the layout of my project directory is :
>> MyProject
>> MathOp
>> Addition.java
>> Multiplication.java
>> Subtraction.java
>> Division.java
>> Operation1
>> some classes
>> Operation2
>> more classes
>> build.xml
>> resulting_classes_directory
>> MANIFEST.1
>>
>> Now I need to be able to include all or the needed classes from
>> MathOp into the compilation of Operation1, and put the results in
>> resulting_classes_directory. I can do this from the command promt
>> using option of javac and it works fine for exmaple I can do :
>> javac -classpath /opt/j2sdk/lib/:/path/to/my/project:Operation1 -d
>> resulting_classes_directory/ Operation1/*.java
>> When I try to do this with ant, it fails complaining about not
>> finding the classes in the package MathOp. I dont want to compile the
>> whole
>> package of MathOp. Please don't suggest this. I want it to be
>> compiled when the classes that needs it is compiled. Here's what I
>> have in my build.xml file.
>>
>> <target name="op1" description="Compiles the Operation 1 and
>> package it">
>> <javac srcdir="Operation1"
>> destdir="resulting_classes_directory" includes="**/*.java" >
>> <classpath>
>> <pathelement path="Operation1"/>
>> <pathelement path="."/>
>> <pathelement path="/path/to/my/project"/>
>> <pathelement path="/opt/j2sdk/lib/"
>> /> <fileset dir="Operation1">
>> <include name="**/*.java"/>
>> </fileset>
>> </classpath>
>> </javac>
>> <jar destfile="Op1.jar" basedir="resulting_classes_directory"
>> manifest="MANIFEST.1" />
>> </target>
>>
>> none of the classes are compiled, "And It Is Important That They Are
>> Compiled Only When Ant Is Invoked."
>> Please let me know what I am missing here, or at least what to search
>> for in google.
>> Thank you in advance.
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: class path problem
Posted by ma...@yahoo.com.
WOW, guys thanks for the fast response, I really appretiate this help.
I am standing in the main directory (MyProject).
When I use -verbose I get alot of output, something like:
[javac] MyOp1.java added as MyOp1.class doesn't exist.
[javac] Op1Helper.java added as Op1Helper.class doesn't exist.
...... then I get:
[javac] Compilation arguments:
[javac] '-d'
[javac] '/path/to/MyProject/resulting_classes_directory'
[javac] '-classpath'
[javac]
'/path/to/MyProject/resulting_classes_directory:/path/to/MyProject/Operation1:
/path/to/MyProject:/opt/j2sdk/lib:/path/to/MyProject/Operation1/MyOp1.java:
......'
There nothing states that the compiler is seeing the classes in the
package MathOp, just like I expected.
I will do a search for how to use sourcepath attribute, and try it. I
'll let you know if it worked, in the mean while, if you have any
suggestion, please let me know.
Thank you for every body.
Scot P. Floess wrote:
> When you execute your ant script, what directory are you "standing"
> in? I see you give a "relative" srcdir of Operation1. Are you
> standing in the directory that Operation1 lives? You may also need to
> use sourcepath attribute.
>
> mansour77@yahoo.com wrote:
>
>> Hi Every Body:
>> I am facing a probelm compile a java application. My Java application
>> uses external and internal library.
>> In other words, let's say i have a package called java.matrix, and
>> I wrote a package for this project called MathOp,
>>
>> the layout of my project directory is :
>> MyProject
>> MathOp
>> Addition.java
>> Multiplication.java
>> Subtraction.java
>> Division.java
>> Operation1
>> some classes
>> Operation2
>> more classes
>> build.xml
>> resulting_classes_directory
>> MANIFEST.1
>>
>> Now I need to be able to include all or the needed classes from
>> MathOp into the compilation of Operation1, and put the results in
>> resulting_classes_directory. I can do this from the command promt
>> using option of javac and it works fine for exmaple I can do :
>> javac -classpath /opt/j2sdk/lib/:/path/to/my/project:Operation1 -d
>> resulting_classes_directory/ Operation1/*.java
>> When I try to do this with ant, it fails complaining about not
>> finding the classes in the package MathOp. I dont want to compile the
>> whole
>> package of MathOp. Please don't suggest this. I want it to be
>> compiled when the classes that needs it is compiled. Here's what I
>> have in my build.xml file.
>>
>> <target name="op1" description="Compiles the Operation 1 and
>> package it">
>> <javac srcdir="Operation1"
>> destdir="resulting_classes_directory" includes="**/*.java" >
>> <classpath>
>> <pathelement path="Operation1"/>
>> <pathelement path="."/>
>> <pathelement path="/path/to/my/project"/>
>> <pathelement path="/opt/j2sdk/lib/"
>> /> <fileset dir="Operation1">
>> <include name="**/*.java"/>
>> </fileset>
>> </classpath>
>> </javac>
>> <jar destfile="Op1.jar" basedir="resulting_classes_directory"
>> manifest="MANIFEST.1" />
>> </target>
>>
>> none of the classes are compiled, "And It Is Important That They Are
>> Compiled Only When Ant Is Invoked."
>> Please let me know what I am missing here, or at least what to search
>> for in google.
>> Thank you in advance.
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: class path problem
Posted by "Scot P. Floess" <fl...@mindspring.com>.
When you execute your ant script, what directory are you "standing" in?
I see you give a "relative" srcdir of Operation1. Are you standing in
the directory that Operation1 lives? You may also need to use
sourcepath attribute.
mansour77@yahoo.com wrote:
> Hi Every Body:
> I am facing a probelm compile a java application. My Java application
> uses external and internal library.
> In other words, let's say i have a package called java.matrix, and I
> wrote a package for this project called MathOp,
>
> the layout of my project directory is :
> MyProject
> MathOp
> Addition.java
> Multiplication.java
> Subtraction.java
> Division.java
> Operation1
> some classes
> Operation2
> more classes
> build.xml
> resulting_classes_directory
> MANIFEST.1
>
> Now I need to be able to include all or the needed classes from MathOp
> into the compilation of Operation1, and put the results in
> resulting_classes_directory. I can do this from the command promt
> using option of javac and it works fine for exmaple I can do :
> javac -classpath /opt/j2sdk/lib/:/path/to/my/project:Operation1 -d
> resulting_classes_directory/ Operation1/*.java
> When I try to do this with ant, it fails complaining about not finding
> the classes in the package MathOp. I dont want to compile the whole
> package of MathOp. Please don't suggest this. I want it to be compiled
> when the classes that needs it is compiled. Here's what I have in my
> build.xml file.
>
> <target name="op1" description="Compiles the Operation 1 and
> package it">
> <javac srcdir="Operation1"
> destdir="resulting_classes_directory" includes="**/*.java" >
> <classpath>
> <pathelement path="Operation1"/>
> <pathelement path="."/>
> <pathelement path="/path/to/my/project"/>
> <pathelement path="/opt/j2sdk/lib/" />
> <fileset dir="Operation1">
> <include name="**/*.java"/>
> </fileset>
> </classpath>
> </javac>
> <jar destfile="Op1.jar" basedir="resulting_classes_directory"
> manifest="MANIFEST.1" />
> </target>
>
> none of the classes are compiled, "And It Is Important That They Are
> Compiled Only When Ant Is Invoked."
> Please let me know what I am missing here, or at least what to search
> for in google.
> Thank you in advance.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org