<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":670,"date":"2021-07-14T00:03:41","date_gmt":"2021-07-14T00:03:41","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=670"},"modified":"2022-04-30T10:09:11","modified_gmt":"2022-04-30T10:09:11","slug":"difference-between-classnotfoundexception-and-noclassdeffounderror-in-java","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/","title":{"rendered":"Difference between ClassNotFoundException and NoClassDefFoundError in java ?"},"content":{"rendered":"<div class=\"row\">\n<div class=\"col-sm-12\">\n<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\" class=\"color-pink\" style=\"text-align: justify;\">Difference between ClassNotFoundException and NoClassDefFoundError in java ?<\/h2>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4209\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif\" alt=\"\" width=\"920\" height=\"709\" \/><\/p>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>ClassNotFoundException and NoClassDefFoundError occur when a particular class is not found at runtime. However, they occur at different scenarios.<\/li>\n<li>ClassNotFoundException is an exception that occurs when you try to load a class at run time using\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/java\/jdbc-resultset\" target=\"_blank\" rel=\"noopener\">Class.forName()<\/a>\u00a0or loadClass() methods and mentioned classes are not found in the classpath.<\/li>\n<li>NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text-center row\" style=\"text-align: justify;\">\n<div class=\"col-sm-12\">\n<div id=\"bsa-zone_1590522538159-8_123456\"><\/div>\n<\/div>\n<\/div>\n<div class=\"table-responsive\">\n<table class=\"table-bordered table-striped table table-responsive\">\n<tbody>\n<tr style=\"text-align: justify;\">\n<th>NoClassDefFoundError<\/th>\n<th>ClassNotFoundException<\/th>\n<\/tr>\n<tr style=\"text-align: justify;\">\n<td class=\"text-leftalign\">NoClassDefFoundError is an error. It is the type of<br \/>\njava.lang.Error.<\/td>\n<td class=\"text-leftalign\">ClassNotFoundException is an exception. It is the type of java.lang.Exception.<\/td>\n<\/tr>\n<tr style=\"text-align: justify;\">\n<td class=\"text-leftalign\">It occurs when java runtime system doesn\u2019t<br \/>\nfind a class definition, which is present at compile time,<br \/>\nbut missing at run time.<\/td>\n<td class=\"text-leftalign\">It occurs when an application tries to load a class at run time which is not updated in the classpath.<\/td>\n<\/tr>\n<tr style=\"text-align: justify;\">\n<td class=\"text-leftalign\">It is thrown by the Java Runtime System.<\/td>\n<td class=\"text-leftalign\">It is thrown by the application itself. It is thrown by the methods like Class.forName(), loadClass() and findSystemClass().<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\" style=\"text-align: justify;\">It occurs when required class definition is missing<br \/>\nat runtime.<\/td>\n<td class=\"text-leftalign\" style=\"text-align: justify;\">It occurs when classpath is not updated wih required JAR files.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-4212\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling.jpg\" alt=\"\" width=\"1366\" height=\"724\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling.jpg 1366w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-300x159.jpg 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-1024x543.jpg 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-768x407.jpg 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-390x207.jpg 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-820x435.jpg 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/java-exception-handling-1180x625.jpg 1180w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Answer : ClassNotFoundException and NoClassDefFoundError occur when a particular&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[4004],"tags":[195,491,360,203,199,214,198,363,4373,4008,4374,4384,4375,209,4376,4377,205,4372,2936,222,196,212,213,15933,286,207,366,4378,4379,4380,4385,204,217,282,4023,483,4381,206,200,197,280,364,4382,4383,968],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-java","tag-accenture-interview-questions-and-answers","tag-applied-materials-interview-questions-and-answers","tag-atos-interview-questions-and-answers","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-chetu-interview-questions-and-answers","tag-ciena-corporation-interview-questions-and-answers","tag-class-not-found-exception-in-eclipse","tag-class-to-java","tag-classnotfoundexception","tag-classnotfoundexception-in-java","tag-classnotfoundexception-java","tag-collabera-technologies-interview-questions-and-answers","tag-custom-exception-handling-in-java","tag-custom-exception-in-java","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-difference-between-classnotfoundexception-and-noclassdeffounderror-in-java","tag-fis-global-business-solutions-india-pvt-ltd-interview-questions-and-answers","tag-flipkart-interview-questions-and-answers","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-infosys-technologies-interview-questions-and-answers","tag-infozech-interview-questions-and-answers","tag-lt-infotech-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-netapp-interview-questions-and-answers","tag-no-class-def-found-error","tag-no-class-def-found-error-java","tag-noclassdeffounderror","tag-noclassdeffounderror-in-java","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-persistent-systems-interview-questions-and-answers","tag-rbs-india-de-interview-questions-and-answers","tag-reliance-industries-ltd-interview-questions-and-answers","tag-runtimeexception","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-tech-mahindra-interview-questions-and-answers","tag-unitedhealth-group-interview-questions-and-answers","tag-virtusa-consulting-services-pvt-ltd-interview-questions-and-answers","tag-wells-fargo-interview-questions-and-answers","tag-what-is-error-in-java","tag-what-is-exception-handling","tag-wipro-infotech-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Difference between ClassNotFoundException and NoClassDefFoundError<\/title>\n<meta name=\"description\" content=\"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Difference between ClassNotFoundException and NoClassDefFoundError\" \/>\n<meta property=\"og:description\" content=\"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-14T00:03:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-30T10:09:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/\",\"name\":\"Difference between ClassNotFoundException and NoClassDefFoundError\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif\",\"datePublished\":\"2021-07-14T00:03:41+00:00\",\"dateModified\":\"2022-04-30T10:09:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif\",\"width\":920,\"height\":709},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Difference between ClassNotFoundException and NoClassDefFoundError","description":"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/","og_locale":"en_US","og_type":"article","og_title":"Difference between ClassNotFoundException and NoClassDefFoundError","og_description":"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/","og_site_name":"Wikitechy","article_published_time":"2021-07-14T00:03:41+00:00","article_modified_time":"2022-04-30T10:09:11+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif"}],"author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/","name":"Difference between ClassNotFoundException and NoClassDefFoundError","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif","datePublished":"2021-07-14T00:03:41+00:00","dateModified":"2022-04-30T10:09:11+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"Difference between ClassNotFoundException and NoClassDefFoundError in java ? - ClassNotFoundException and NoClassDefFoundError occur","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/difference-between-classnotfoundexception-and-noclassdeffounderror-in-java\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2021\/07\/classnotfoundexception-vs-noclassdeffounderror.gif","width":920,"height":709},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":4,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":4213,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/670\/revisions\/4213"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}