gpt4 book ai didi

java - 如何从使用 Eclipse 进行构建过渡到使用 Ant

转载 作者:行者123 更新时间:2023-12-01 19:15:01 24 4
gpt4 key购买 nike

我在 Eclipse Helios 中有一个 Spring Web 应用程序。我在其他项目上使用 Ant 进行构建,但不熟悉最初设置 Ant 构建文件。是否有一种轻松的方法可以从使用 Eclipse 进行构建过渡到创建 Ant 构建文件和任何支持文件?我尝试将基本的 Ant 构建文件复制到我的应用程序中,但我不确定它是否接近我的需要。我已将其包含在下面。当我运行它时,它给了我这个错误。

BUILD FAILED
C:\..\..\workspace\..\build.xml:21: 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.

我的系统JAVA_HOME路径设置为'C:\Program Files\Java\jdk1.7.0\bin'

<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" default="dist" basedir=".">
<description>
build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>

<!-- Put everything in ${build} into the News-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/ProjectName-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>

最佳答案

请勿在 JAVA_HOME 中包含 bin 文件夹

试试这个:

C:\Program Files\Java\jdk1.7.0

关于java - 如何从使用 Eclipse 进行构建过渡到使用 Ant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7073077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com