Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Best way to add classpath to build.xml

Writer Olivia Zamora

I have this target in build.xml to compile a class:

<target name="-do-compile" depends="init, deps-jar, -pre-pre-compile, -pre-compile, -copy-manifest, -copy-persistence-xml, -copy-webdir, library-inclusion-in-archive,library-inclusion-in-manifest" if="have.sources"> <webproject2:javac destdir="${build.classes.dir.real}"/> <copy todir="${build.classes.dir.real}"> <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> </copy>
</target>

There is also this:

<target name="-init-macrodef-javac"> <macrodef name="javac" uri=""> <attribute name="srcdir" default="${src.dir}"/> <attribute name="destdir" default="${build.classes.dir.real}"/> <attribute name="classpath" default="${javac.classpath}:${j2ee.platform.classpath}"/> <attribute name="debug" default="${javac.debug}"/> <element name="customize" optional="true"/> <sequential> <javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> <classpath> <path path="@{classpath}"/> </classpath> <compilerarg line="${javac.compilerargs}"/> <customize/> </javac> </sequential> </macrodef> </target>

During compilation, I got an error 'javax.servlet does not exist'. So I have to add classpath to servlet-api.jar, which is in /opt/java/common/. What is the best way to do it in my build.xml, what should be modified?

As the question may look silly, one may downvote instead of answering. But this certainly won't help, which is what they are here for.

1 Answer

Add below line to your classpath element

<pathelement location="/opt/java/common/servlet-api.jar"/>

i.e in your build xml file

<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> <classpath> <path path="@{classpath}"/> <pathelement location="/opt/java/common/servlet-api.jar"/> </classpath> <compilerarg line="${javac.compilerargs}"/> <customize/>
</javac>

Please see Path-like Structures Section

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy