I have a build file that declares the classpath as shown
<path id="compile.classpath">
<fileset dir="${basedir}/lib" includes="**"/>
<fileset dir="${jboss.home}/lib" includes="**"/>
<pathelement path ="${build.classes.dir}"/>
</path>
I tried looking at the documentation but I am not able to understand the use of
pathelement
.
I know that the ID is used to refer to this class path while performing a task and fileset includes the jarfiles.
edit 1:
My doubt is Why can't we use fileset
to include the class files in place of pathelement
?
Latest edit:
My doubt is Why can't we use fileset to include the class files in place of pathelement?
If you use a fileset then you'd be adding a set of class files to the path as follows:
CLASSPATH=classes/MyClass1.class:classes/MyClass2.class:classes/MyClass3.class:....
When what Java expects to see is simply:
CLASSPATH=classes
Only jar (and WAR,EAR,etc) files are explicitly listed on the classpath (Java will open them up and load their class files), hence the need for a fileset in ANT.
Here's the Oracle documentation:
Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to:
- For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
- For .class files in an unnamed package, the class path ends with the directory that contains the .class files.
- For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With