javac -classpath "/installs/hadoop-0.20.2/*.jar;/installs/hadoop-0.20.2/lib/*.jar" appClientModule/grid/comp/tools/CleanTmp.java
appClientModule/grid/comp/tools/CleanTmp.java:2: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.*;
^
appClientModule/grid/comp/tools/CleanTmp.java:3: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.JobConf;
^
appClientModule/grid/comp/tools/CleanTmp.java:4: package org.apache.commons.logging does not exist
import org.apache.commons.logging.*;
^
appClientModule/grid/comp/tools/CleanTmp.java:5: package org.apache.commons.logging.impl does not exist
import org.apache.commons.logging.impl.Log4JLogger;
^
appClientModule/grid/comp/tools/CleanTmp.java:8: cannot find symbol
symbol : class Log4JLogger
location: class grid.comp.tools.CleanTmp
Log4JLogger lg=new Log4JLogger(this.getClass().getName());
^
appClientModule/grid/comp/tools/CleanTmp.java:9: cannot find symbol
symbol : class JobConf
location: class grid.comp.tools.CleanTmp
JobConf jconf;
^
appClientModule/grid/comp/tools/CleanTmp.java:8: cannot find symbol
symbol : class Log4JLogger
location: class grid.comp.tools.CleanTmp
Log4JLogger lg=new Log4JLogger(this.getClass().getName());
^
7 errors
tools $ javac -classpath "/installs/hadoop-0.20.2/*.jar;/installs/hadoop-0.20.2/lib/*.jar" appClientModule/grid/comp/tools/CleanTmp.java
jabir:CompareHdfs jabir.ahmed$ javac -classpath "/installs/hadoop-0.20.2/*.jar;/installs/hadoop-0.20.2/lib/*.jar" appClientModule/grid/comp/tools/CleanTmp.java
appClientModule/grid/comp/tools/CleanTmp.java:2: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.*;
^
appClientModule/grid/comp/tools/CleanTmp.java:3: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.JobConf;
^
appClientModule/grid/comp/tools/CleanTmp.java:4: package org.apache.commons.logging does not exist
import org.apache.commons.logging.*;
^
appClientModule/grid/comp/tools/CleanTmp.java:5: package org.apache.commons.logging.impl does not exist
import org.apache.commons.logging.impl.Log4JLogger;
^
appClientModule/grid/comp/tools/CleanTmp.java:8: cannot find symbol
symbol : class Log4JLogger
location: class grid.comp.tools.CleanTmp
Log4JLogger lg=new Log4JLogger(this.getClass().getName());
^
appClientModule/grid/comp/tools/CleanTmp.java:9: cannot find symbol
symbol : class JobConf
location: class grid.comp.tools.CleanTmp
JobConf jconf;
^
appClientModule/grid/comp/tools/CleanTmp.java:8: cannot find symbol
symbol : class Log4JLogger
location: class grid.comp.tools.CleanTmp
Log4JLogger lg=new Log4JLogger(this.getClass().getName());
^
7 errors
tools $ ls /installs/hadoop-0.20.2/lib/*.jar
/installs/hadoop-0.20.2/lib/ant-contrib-1.0b3.jar /installs/hadoop-0.20.2/lib/jasper-runtime-5.5.12.jar
/installs/hadoop-0.20.2/lib/aspectjrt-1.6.5.jar /installs/hadoop-0.20.2/lib/jets3t-0.6.1.jar
/installs/hadoop-0.20.2/lib/aspectjtools-1.6.5.jar /installs/hadoop-0.20.2/lib/jetty-6.1.26.cloudera.1.jar
/installs/hadoop-0.20.2/lib/commons-cli-1.2.jar /installs/hadoop-0.20.2/lib/jetty-servlet-tester-6.1.26.cloudera.1.jar
/installs/hadoop-0.20.2/lib/commons-codec-1.4.jar /installs/hadoop-0.20.2/lib/jetty-util-6.1.26.cloudera.1.jar
/installs/hadoop-0.20.2/lib/commons-daemon-1.0.1.jar /installs/hadoop-0.20.2/lib/jsch-0.1.42.jar
/installs/hadoop-0.20.2/lib/commons-el-1.0.jar /installs/hadoop-0.20.2/lib/junit-4.5.jar
/installs/hadoop-0.20.2/lib/commons-httpclient-3.1.jar /installs/hadoop-0.20.2/lib/kfs-0.2.2.jar
/installs/hadoop-0.20.2/lib/commons-logging-1.0.4.jar /installs/hadoop-0.20.2/lib/log4j-1.2.15.jar
/installs/hadoop-0.20.2/lib/commons-logging-api-1.0.4.jar /installs/hadoop-0.20.2/lib/mockito-all-1.8.2.jar
/installs/hadoop-0.20.2/lib/commons-net-1.4.1.jar /installs/hadoop-0.20.2/lib/oro-2.0.8.jar
/installs/hadoop-0.20.2/lib/core-3.1.1.jar /installs/hadoop-0.20.2/lib/servlet-api-2.5-20081211.jar
/installs/hadoop-0.20.2/lib/hadoop-fairscheduler-0.20.2-cdh3u2.jar /installs/hadoop-0.20.2/lib/servlet-api-2.5-6.1.14.jar
/installs/hadoop-0.20.2/lib/hsqldb-1.8.0.10.jar /installs/hadoop-0.20.2/lib/slf4j-api-1.4.3.jar
/installs/hadoop-0.20.2/lib/jackson-core-asl-1.5.2.jar /installs/hadoop-0.20.2/lib/slf4j-log4j12-1.4.3.jar
/installs/hadoop-0.20.2/lib/jackson-mapper-asl-1.5.2.jar /installs/hadoop-0.20.2/lib/xmlenc-0.52.jar
/installs/hadoop-0.20.2/lib/jasper-compiler-5.5.12.jar## Heading ##
那么我该如何设置类路径
我尝试通过env变量进行设置
$ echo $ CLASSPATH /installs/hadoop/lib/.jar:/installs/hadoop/.jar:/installs/hadoop-0.20.2/.jar:/installs/hadoop-0.20.2/lib / 的.jar
它仍然失败
$ javac -version javac 1.6.0_29
答案 0 :(得分:6)
寻找更清晰的类路径,如:
javac -classpath $HADOOP_HOME/hadoop-core-0.20.204.0.jar:$HADOOP_HOME/lib/commons-cli-1.2.jar -d inception src/Inception.java
(在这种情况下,Inception是你的java程序。不知道为什么我提到了这个但是最好更明确一点然后不是!)
如果您使用工具界面,大多数情况下您将需要hadoop-core-(yourversion)和commons-cli。
答案 1 :(得分:0)
如果已设置CLASSPATH变量,则无需在javac命令中指定-classpath标志,因为它将从环境变量CLASSPATH中获取类路径值
classpath的值需要指向实际的jar文件而不是.jar 例如,
set CLASSPATH=/myapp/mylib.jar
根据您所使用的平台,您可以使用:或;作为不同路径之间的分隔符。对于Windows,请使用;和UNIX通常使用:
在UNIX中:
set CLASSPATH=/myapp/myclasses1.jar:/myapp/myclasses2.jar
但在Windows中,您需要使用分号作为路径之间的分隔符
set CLASSPATH=/myapp/myclasses1.jar;/myapp/myclasses2.jar
答案 2 :(得分:0)
查询的解决方案帮助了我。以下是我在HDInsight 2.1版上使用的语法:
C:\ apps \ dist \ java \ bin \ javac -classpath%HADOOP_HOME%\ hadoop-core-1.2.0.1.3.0.1-0302.jar;%HADOOP_HOME%\ lib \ commons-cli-1.2.jar WordCount.java
答案 3 :(得分:0)
不要指定单个库,只需添加" -classpath yarn classpath
"。这使得命令非常简单。