When I try to build my struts project in Eclipse I get the following
error in the console.
Buildfile: F:\eclipse\eclipse\workspace\strutsTutorial\build.xml
clean:
[delete] Deleting directory
F:\eclipse\eclipse\workspace\strutsTutorial\WEB-INF\classes
prep:
[mkdir] Created dir:
F:\eclipse\eclipse\workspace\strutsTutorial\WEB-INF\classes
cleanWebApp:
compile:
[javac] Compiling 1 source file to
F:\eclipse\eclipse\workspace\strutsTutorial\WEB-INF\classes
BUILD FAILED: F:\eclipse\eclipse\workspace\strutsTutorial\build.xml:40:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
Total time: 2 seconds
After which the build process stops.
My build.xml file contains the following
<project name="StrutsBox Blank Project" default="main" basedir=".">
<!-- This is a basic build script, only the minimums here -->
<!-- Tell ant to use my environment variables -->
<property environment="env"/>
<property file="./build.properties"/>
<property name="build.compiler" value="modern"/>
<property name="build.dir" value="./WEB-INF/classes" />
<property name="src.dir" value="./WEB-INF/src"/>
<property name="war.file" value="struts-example"/>
<property name="war.file.name" value="${war.file}.war"/>
<property name="tomcat.home" value="${env.CATALINA_HOME}"/>
<property name="deploy.dir" value="${tomcat.home}/webapps"/>
<property name="servlet.jar"
value="${tomcat.home}/common/lib/servlet-api.jar"/>
<path id="project.class.path">
<fileset dir="./WEB-INF/lib/">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${src.dir}"/>
<pathelement path="${servlet.jar}"/>
</path>
<target name="clean">
<delete dir="${build.dir}" includeEmptyDirs="true" />
</target>
<target name="prep">
<mkdir dir="${build.dir}"/>
</target>
<target name="compile">
<javac srcdir="${src.dir}"
destdir="${build.dir}"
debug="on"
deprecation="on">
<include name="**/*.java"/>
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="cleanWebApp">
<delete file="${deploy.dir}/${war.file.name}" />
<delete dir="${deploy.dir}/${war.file}"
includeEmptyDirs="true" />
</target>
<target name="war">
<war warfile="${war.file.name}" webxml="./WEB-INF/web.xml">
<fileset dir="./" includes="**/*.*" excludes="*.war,
**/*.nbattrs, web.xml, **/WEB-INF/**/*.*, **/project-files/**/*.*"/>
<webinf dir="./WEB-INF" includes="**/*"
excludes="web.xml, **/*.jar, **/*.class"/>
<lib dir="./WEB-INF/lib"/>
<classes dir="${build.dir}" includes="**/*.properties" />
</war>
</target>
<target name="deploy">
<copy todir="${deploy.dir}">
<fileset dir="./" includes="${war.file.name}"/>
</copy>
</target>
<target name="main" depends="clean, prep, cleanWebApp, compile, war"/>
</project>
It appears to me that I need to specify in the build file where to find
the javac executable. I have a classpath set in my system environment
variables but this does not seem to be found by the build process.
Can anyone help me with this problem?