Eclipse appears exception in thread "main" Java.lang.NoClassDefFoundError

Source: Internet
Author: User

Last night, while running the Hadoop program, a new project was created and somehow it always appeared exception in thread "main" Java.lang.NoClassDefFoundError

The error is as follows:

Exception in thread "main" Java.lang.noclassdeffounderror:wordcount/class
caused By:java.lang.ClassNotFoundException:WordCount.class
At Java.net.urlclassloader$1.run (urlclassloader.java:217)
At Java.security.AccessController.doPrivileged (Native method)
At Java.net.URLClassLoader.findClass (urlclassloader.java:205)
At Java.lang.ClassLoader.loadClass (classloader.java:321)
At Sun.misc.launcher$appclassloader.loadclass (launcher.java:294)
At Java.lang.ClassLoader.loadClass (classloader.java:266)
Could not find the main class:WordCount.class. Program would exit.

I've been trying a lot of ways, including:

1. Modify Classpath

2. Modify Path

3, in Eclipse's property-> Java build Path-> Libraries-> Add External Jars, add Tools.jat, Dt.jar all

All right, try reloading eclipse, suddenly brainwave, think of the run as-> run configurations-> Main, as shown in the following figure:


Get rid of the circle's ". Class" and it's OK.


The following is a successful operation:

13/07/21 10:28:58 INFO JVM. Jvmmetrics:initializing JVM Metrics with Processname=jobtracker, sessionid=
13/07/21 10:28:58 WARN mapred. Jobclient:use Genericoptionsparser for parsing the arguments. Applications should implement Tool for the same.
13/07/21 10:28:58 WARN mapred.  Jobclient:no job jar file set. User classes May is found. Jobconf (Class) or Jobconf#setjar (String).
13/07/21 10:28:58 INFO input. Fileinputformat:total input paths to process:1
13/07/21 10:29:03 INFO mapred. Jobclient:running job:job_local_0001
13/07/21 10:29:03 INFO input. Fileinputformat:total input paths to process:1
13/07/21 10:29:03 INFO mapred. MAPTASK:IO.SORT.MB = 100
13/07/21 10:29:05 INFO mapred. Jobclient:map 0% Reduce 0%
13/07/21 10:29:05 INFO mapred. Maptask:data buffer = 79691776/99614720
13/07/21 10:29:05 INFO mapred. Maptask:record buffer = 262144/327680
13/07/21 10:29:05 INFO mapred. maptask:starting Flush of map output
13/07/21 10:29:05 INFO mapred. Maptask:finished spill 0
13/07/21 10:29:05 INFO mapred. TaskRunner:Task:attempt_local_0001_m_000000_0 is done. and is in the process of commiting
13/07/21 10:29:05 INFO mapred. Localjobrunner:
13/07/21 10:29:05 INFO mapred. Taskrunner:task ' Attempt_local_0001_m_000000_0 ' done.
13/07/21 10:29:05 INFO mapred. Localjobrunner:
13/07/21 10:29:05 INFO mapred. Merger:merging 1 sorted Segments
13/07/21 10:29:05 INFO mapred. Merger:down to the last Merge-pass, with 1 segments left of total size:34 bytes
13/07/21 10:29:05 INFO mapred. Localjobrunner:
13/07/21 10:29:05 INFO mapred. TaskRunner:Task:attempt_local_0001_r_000000_0 is done. and is in the process of commiting
13/07/21 10:29:05 INFO mapred. Localjobrunner:
13/07/21 10:29:05 INFO mapred. Taskrunner:task Attempt_local_0001_r_000000_0 is allowed to commit now
13/07/21 10:29:05 INFO output. fileoutputcommitter:saved output of Task ' attempt_local_0001_r_000000_0 ' to output
13/07/21 10:29:05 INFO mapred. Localjobrunner:reduce > Reduce
13/07/21 10:29:05 INFO mapred. Taskrunner:task ' Attempt_local_0001_r_000000_0 ' done.
13/07/21 10:29:06 INFO mapred. Jobclient:map 100% Reduce 100%
13/07/21 10:29:06 INFO mapred. Jobclient:job complete:job_local_0001
13/07/21 10:29:06 INFO mapred. Jobclient:counters:12
13/07/21 10:29:06 INFO mapred. Jobclient:filesystemcounters
13/07/21 10:29:06 INFO mapred. jobclient:file_bytes_read=26254
13/07/21 10:29:06 INFO mapred. jobclient:file_bytes_written=53072
13/07/21 10:29:06 INFO mapred. Jobclient:map-reduce Framework
13/07/21 10:29:06 INFO mapred. Jobclient:reduce input groups=4
13/07/21 10:29:06 INFO mapred. Jobclient:combine Output records=4
13/07/21 10:29:06 INFO mapred. Jobclient:map input Records=1
13/07/21 10:29:06 INFO mapred. Jobclient:reduce Shuffle bytes=0
13/07/21 10:29:06 INFO mapred. Jobclient:reduce Output records=4
13/07/21 10:29:06 INFO mapred. Jobclient:spilled records=8
13/07/21 10:29:06 INFO mapred. Jobclient:map Output bytes=54
13/07/21 10:29:06 INFO mapred. Jobclient:combine input Records=9
13/07/21 10:29:06 INFO mapred. Jobclient:map Output records=9
13/07/21 10:29:06 INFO mapred. Jobclient:reduce input records=4

A bug really can make people crazy ... You don't know how to die before you solve a bug ...

Hope to give a little help to the students who meet this bug.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.