我的构建脚本如下:
<project default="main">
<target name="main" depends="clear,compile,jar">
</target>
<target name="clear">
<delete includeemptydirs="true">
<fileset dir="../bin" includes="**/*" />
</delete>
</target>
<target name="compile">
<javac srcdir="../src" destdir="../bin" />
</target>
<target name="jar">
<jar destfile="../jms.jar">
<fileset dir="../bin">
<include name="**/*.class" />
</fileset>
<zipgroupfileset dir="C:/Users/Jason/Project/apache-activemq-5.9" includes="activemq-5.9.jar" />
<manifest>
<section name="Information">
<attribute name="Version" value="1.1-02" />
</section>
</manifest>
</jar>
</target>
</project>
由于JAR丢失,我仍然收到无法编译类的错误。我加错了吗?
C:\Users\Jason\Project\Workspace\ActiveMQ\src包含所有源文件C:\Users\Jason\Project\apache-activemq-5.9是JAR文件的目标位置
以下是我的错误:
Buildfile: C:\Users\Jason\Project\Workspace\ActiveMQ\src\build.xml
clear:
compile:
[javac] C:\Users\Jason\Project\Workspace\ActiveMQ\src\build.xml:12: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 2 source files to C:\Users\Jason\Project\Workspace\ActiveMQ\bin
[javac] C:\Users\Jason\Project\Workspace\ActiveMQ\src\Publisher.java:1: error: package org.apache.activemq does not exist
[javac] import org.apache.activemq.ActiveMQConnectionFactory;
[javac] ^
[javac] C:\Users\Jason\Project\Workspace\ActiveMQ\src\Publisher.java:2: error: package javax.jms does not exist
[javac] import javax.jms.*;
[javac] ^
[javac] C:\Users\Jason\Project\Workspace\ActiveMQ\src\Publisher.java:7: error: cannot find symbol
[javac] ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
[javac] ^
[javac] symbol: class ActiveMQConnectionFactory
[javac] location: class Publisher
[javac] C:\Users\Jason\Project\Workspace\ActiveMQ\src\Publisher.java:7: error: cannot find symbol
[javac] ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
[javac] ^
[javac] symbol: class ActiveMQConnectionFactory
[javac] location: class Publisher
[javac] 4 errors
发布于 2017-05-09 20:26:10
您应该向javac目标添加一个类路径,例如
<javac srcdir="../src" destdir="../bin" classpath="your-jar-file"/>
有关添加类路径的更多选项,请参阅Javac Task documentation。
https://stackoverflow.com/questions/43878858
复制相似问题