在运行我的 java 程序以将文件复制到 hdfs 时,我遇到了以下异常
hduser@master:~/Desktop/Source Code$ java -cp . Filesize monis.txt /home/hduser/Desktop/Source*/monis.txt /tmp/user/gutenberg
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration
at FileSize.copyFromLocal(FileSize.java:219)
at FileSize.main(FileSize.java:74)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 2 more
我已经CLASSPATH
在文件中定义了我的变量/etc/environment
,它看起来像这样
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
CLASSPATH="/usr/local/hadoop/hadoop-core-1.0.4.jar:/usr/local/hadoop/lib/commons-cli-1.2.jar:/usr/local/hadoop/lib/commons-logging-1.1.1.jar:/usr/local/hadoop/lib/log4j-1.2.15.jar:/home/hduser/Desktop/Source*/"
我仍然得到这个例外。