• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException vs NoClassDefFoundError

 
Ceppad Reso
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between these two as in CLDC1.1 API:
1. java.lang.NoClassDefFoundError
2. java.lang.ClassNotFoundException
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Since the libraries included in CLDC are generally intended to be highly compatible with J2SE libraries, the library classes included in CLDC shall throw precisely the same exceptions as regular J2SE classes do. Consequently, a fairly comprehensive set of exception classes has been included.


java.lang.ClassNotFoundException fits into this category and is an Exception and could be caught in a try/catch block
whereas
java.lang.NoClassDefFoundError is an error and is covered by this paragraph in the spec.
In contrast, as explained in Section 4.2 �Exception and Error Handling Limitations,� the error handling capabilities of CLDC are limited. By default, a virtual machine conforming to CLDC is required to support only the error classes listed below in Section 6.2.7.2 �Error classes.�

Errors cannot be caught in code and will terminate MIDlet execution.
Hope that helps.
 
Ceppad Reso
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic