轉自http://www.blogjava.net/snoics/archive/2010/10/10/333408.htmlhtml
在Window下啓動Hadoop-0.21.0版本時,會出現下面這樣的錯誤提示:java
1
java.lang.NoClassDefFoundError: org
/
apache
/
hadoop
/
util
/
PlatformName
2
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.PlatformName
3
4
at java.net.URLClassLoader$
1
.run(URLClassLoader.java:
202
)
5
at java.security.AccessController.doPrivileged(Native Method)
6
at java.net.URLClassLoader.findClass(URLClassLoader.java:
190
)
7
at java.lang.ClassLoader.loadClass(ClassLoader.java:
307
)
8
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301
)
9
at java.lang.ClassLoader.loadClass(ClassLoader.java:
248
)
10
Could not find the main
class
: org.apache.hadoop.util.PlatformName. Program wil
11
l exit.
通過不斷的查找緣由和嘗試,終於有了解決這個錯誤的辦法,只須要將${HADOOP_HOME}/bin/hadoop-config.sh文件中的第190行的一下的內容
JAVA_PLATFORM
=
`CLASSPATH
=
${CLASSPATH} ${JAVA}
-
Xmx32m ${HADOOP_JAVA_PLATFORM_OPTS} org.apache.hadoop.util.PlatformName
|
sed
-
e
"
s/ /_/g
"
`
修改爲如下的內容便可
JAVA_PLATFORM
=
`CLASSPATH
=
${CLASSPATH} ${JAVA}
-
Xmx32m
-
classpath ${HADOOP_COMMON_HOME}
/
hadoop
-
common
-
0.21
.
0
.jar org.apache.hadoop.util.PlatformName
|
sed
-
e
"
s/ /_/g
"
`