如何从javac类路径设置项目的类路径



我得到以下错误:"从javac类路径设置项目的类路径时出现问题:C:\usr\share\hadoop不存在。"我不确定错误是怎么说的。我查看了构建文件,没有看到任何对该类路径的引用。

构建文件,即build.xml,如下所示:

<project name="Common Crawl Examples" default="dist" basedir=".">
  <description>
    Common Crawl Examples Build File
  </description>
  <!-- set global properties for this build -->
  <property name="name" value="commoncrawl-examples" />
  <loadfile srcfile="${basedir}/VERSION" property="version">
    <filterchain>
      <striplinebreaks />
    </filterchain>
  </loadfile>
  <!-- include any user specific or environment specifc build properties -->
  <property file="${user.home}/build.properties"/>
  <property file="${basedir}/build.properties"/>
  <!-- ensure that 'hadoop.path' is set -->
  <fail message="Please define the 'hadoop.path' property in this 'build.properties' file">
    <condition>
      <not>
        <isset property="hadoop.path"/>
      </not>
    </condition>
  </fail>
  <property name="lib"   location="lib"  />
  <property name="src"   location="src"  />
  <property name="build" location="build"/>
  <property name="dist"  location="dist" />
  <property name="test"  location="test" />
  <target name="init">
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>
  <target name="compile" depends="init"
          description="compile the source" >
    <echo message=""/>
    <echo message="Building '${name}': Version ${version}"/>
    <echo message=""/>
    <javac srcdir="${src}" destdir="${build}" debug="on" debuglevel="lines,vars,source" target="1.6">
      <compilerarg value="-Xlint"/>
      <classpath>
        <pathelement path="${classpath}"/>
        <fileset dir="${hadoop.path}">
          <include name="**/hadoop-core-*.jar"/>
          <include name="**/log4j-*.jar"/>
          <include name="**/junit-*.jar"/>
        </fileset>
        <fileset dir="lib">
          <include name="**/*.jar"/>
        </fileset>
      </classpath>
    </javac>
  </target>
  <target name="dist" depends="compile"
          description="generate the distribution" >
    <mkdir dir="${dist}/lib"/>
    <mkdir dir="${build}/lib"/>
    <jar jarfile="${dist}/lib/${name}-${version}.jar" basedir="${build}">
      <zipfileset dir="lib" prefix="lib" >
        <include name="**/*.jar" />
      </zipfileset>
    </jar>
  </target>
  <target name="compile-tests" depends="dist"
          description="compile test cases" >
    <mkdir dir="${build}-test"/>
    <javac srcdir="${test}" destdir="${build}-test" debug="on" debuglevel="lines,vars,source" target="1.6">
      <compilerarg value="-Xlint"/>
      <classpath>
        <pathelement path="${classpath}"/>
        <pathelement path="/usr/share/java/junit.jar"/>
        <fileset dir="${hadoop.path}">
          <include name="**/hadoop-core-*.jar"/>
          <include name="**/log4j-*.jar"/>
        </fileset>
        <fileset dir="lib">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement path="${dist}/lib/${name}-${version}.jar"/>
      </classpath>
    </javac>
  </target>
  <target name="test" depends="compile-tests"
          description="run Junit test cases" >
    <junit printsummary="true">
      <classpath>
        <pathelement path="${classpath}"/>
        <pathelement path="/usr/share/java/junit.jar"/>
        <fileset dir="${hadoop.path}">
          <include name="**/hadoop-core-*.jar"/>
          <include name="**/log4j-*.jar"/>
        </fileset>
        <fileset dir="lib">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement path="${dist}/lib/${name}-${version}.jar"/>
        <pathelement path="${build}-test"/>
      </classpath>
      <batchtest>
        <fileset dir="${build}-test"/>
        <formatter type="plain" usefile="false"/>
      </batchtest>
    </junit>
  </target>
  <target name="clean"
          description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${build}-test"/>
    <delete dir="${dist}"/>
  </target>
</project>

你知道这个错误指的是什么吗?

谢谢你,我很感激你的指点。我通读了关于类似问题的帖子,但似乎没有一个解决方案能解决我的问题。

条件<isset property="hadoop.path"/>检查属性hadoop.path是否在之前加载的build.properties文件中定义
查看这些文件以获取hadoop.path=C:usrsharehadoop的定义
<echoproperties prefix="hadoop"/>放在<property file=.../>之后,以获得所有hadopp.xx属性的响应,或增加loglevel=>ant -f yourbuild.xml -debug
以查看所有属性和详细信息
如果hadoop.path没有在那里定义,那么它必须设置为userproperty,这意味着您的ant脚本是用ant -f yourbuild.xml -Dhadoop.path=...启动的
在Eclipse中,您将使用ant编辑器或导航器中的上下文菜单,并:
Run As | 2 AntBuild...,然后在Edit Configuration窗口中选择Main Tab并放入
-Dhadoop.path=whateveryoulike转换为Arguments以设置您的用户属性
日志级别也是通过Main|Arguments设置的,只需将-debug或-verbose放入即可。

相关内容

  • 没有找到相关文章

最新更新