使用外部 JAR 构建 Eclipse 项目



我的构建脚本如下:

<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:UsersJasonProjectWorkspaceActiveMQsrcbuild.xml
clear:
compile:
    [javac] C:UsersJasonProjectWorkspaceActiveMQsrcbuild.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:UsersJasonProjectWorkspaceActiveMQbin
    [javac] C:UsersJasonProjectWorkspaceActiveMQsrcPublisher.java:1: error: package org.apache.activemq does not exist
    [javac] import org.apache.activemq.ActiveMQConnectionFactory;
    [javac]                           ^
    [javac] C:UsersJasonProjectWorkspaceActiveMQsrcPublisher.java:2: error: package javax.jms does not exist
    [javac] import javax.jms.*;
    [javac] ^
    [javac] C:UsersJasonProjectWorkspaceActiveMQsrcPublisher.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:UsersJasonProjectWorkspaceActiveMQsrcPublisher.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

你应该向javac目标添加一个类路径,例如

<javac srcdir="../src" destdir="../bin" classpath="your-jar-file"/>

有关添加类路径的更多选项,请参阅 Javac 任务文档。

相关内容

  • 没有找到相关文章

最新更新