gpt4 book ai didi

java - 当我尝试使用此 Ant 脚本进行编译时,为什么会出现这些错误?

转载 作者:行者123 更新时间:2023-11-30 04:12:27 25 4
gpt4 key购买 nike

我对 Ant 很陌生(我来自 Maven),我发现这个简单的 Ant 脚本编译位于 Eclipse 工作区中的 Java 项目有一些困难:

Ant脚本代码是:

<?xml version="1.0"?>
<project>

<!-- ============================================ -->
<!-- Load build properties -->
<!-- ============================================ -->

<property name="project.buildfile" value="build.num" />
<property file="${project.buildfile}" />
<property file="info.properties" />

<!-- Elimina le cartelle contenenti le classi compilate ed i jar -->
<target name="clean">
<delete dir="../Release" />
<!-- Elimina directory del jar finale -->
<delete dir="bin" />
<!-- Elimina directory delle classi compilate -->
</target>

<target name="compile">
<mkdir dir="bin" />
<javac srcdir="src" destdir="bin" />
</target>
</project>

所以这个脚本有一个名为clean的第一个目标,它只需将2个目录删除到我的项目中(这部分工作得很好)

另一个目标名为compile,它实现了与项目编译相关的 2 个简单任务:

1)在我的项目中创建一个名为bin的目录(这样就可以了)

2) 编译src项目文件夹中的源代码,并将.class文件放入bin目录中。

这里我遇到了一些问题,因为当我执行这个 ant 脚本时,我收到这些错误消息:

Buildfile: /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/build.xml
clean:
[delete] Deleting directory /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/bin
compile:
[mkdir] Created dir: /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/bin
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/build.xml:22: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 35 source files to /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/bin
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Settings.java:12: package org.apache.log4j does not exist
[javac] import org.apache.log4j.Logger;
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Settings.java:14: package com.adamtaft.eb does not exist
[javac] import com.adamtaft.eb.EventBusService;
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Settings.java:26: cannot find symbol
[javac] symbol : class Logger
[javac] location: class com.techub.crystalice.xmlhandler.Settings
[javac] public static final Logger logger = Logger.getLogger("gui");
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Utils.java:9: package org.apache.log4j does not exist
[javac] import org.apache.log4j.Logger;
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Utils.java:16: cannot find symbol
[javac] symbol : class Logger
[javac] location: class com.techub.crystalice.xmlhandler.Utils
[javac] private static final Logger logger = Logger.getLogger("gui");
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Settings.java:26: cannot find symbol
[javac] symbol : variable Logger
[javac] location: class com.techub.crystalice.xmlhandler.Settings
[javac] public static final Logger logger = Logger.getLogger("gui");
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Settings.java:130: cannot find symbol
[javac] symbol : variable EventBusService
[javac] location: class com.techub.crystalice.xmlhandler.Settings
[javac] EventBusService.publish(new SettingsEvent(this, SettingsEventType.UPDATED));
[javac] ^
[javac] /home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/src/com/techub/crystalice/xmlhandler/Utils.java:16: cannot find symbol
[javac] symbol : variable Logger
[javac] location: class com.techub.crystalice.xmlhandler.Utils
[javac] private static final Logger logger = Logger.getLogger("gui");
[javac] ^
[javac] 8 errors
BUILD FAILED
/home/andrea/Documenti/XCloud/Implementazione/CrossPlatform/CrystalIceXMLHandler/Project/build.xml:22: Compile failed; see the compiler error output for details.
Total time: 1 second

为什么我会出现这些错误?怎么解决?

Tnx

安德里亚

最佳答案

ant 似乎无法找到所需的库/jar。您需要在这两个地方之一拥有所需的库/jar:

  1. ANT_HOME/lib
  2. 用户特定目录,${user.home}/.ant/lib

关于java - 当我尝试使用此 Ant 脚本进行编译时,为什么会出现这些错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19296218/

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