Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

This appendix contains a list of run-time exceptions and errors produced by the

Java language and the classes of the Java standard class library. It is not an
exhaustive list, but it does contain most of the exceptions and errors that arise in
programs within the scope of this text.
K

java exceptions and errors


Both exceptions and errors indicate that a problem has occurred while a pro-
gram was executing. Exceptions can be caught and handled under programmer
control using the Java try statement. Errors represent more serious problems
and generally should not be caught. Some exceptions and errors indicate the same
type of problem, such as NoSuchMethodException and NoSuchMethodError. In
these cases, the particular situation in which the problem arises determines
whether an exception or an error is thrown.

exceptions
AccessControlException (java.security)
Requested access to a critical system resource is denied.
ArithmeticException (java.lang)
An illegal arithmetic operation was attempted, such as dividing by zero.
ArrayIndexOutOfBoundsException (java.lang)
An index into an array object is out of range.
ArrayStoreException (java.lang)
An attempt was made to assign a value to an array element of an incompatible
type.
AWTException (java.awt)
A general exception indicating that some problem has occurred in a class of
the java.awt package.
BindException (java.net)
A socket could not be bound to a local address and port.
ClassCastException (java.lang)
An attempt was made to cast an object reference to an incompatible type.
ClassNotFoundException (java.lang)
A specific class or interface could not be found.
CloneNotSupportedException (java.lang)
An attempt was made to clone an object instantiated from a class that does not
implement the Cloneable interface.
742 APPENDIX K java exceptions and errors

EmptyStackException (java.util)
An attempt was made to reference an element from an empty stack.
EOFException (java.io)
The end of file has been encountered before normal completion of an input
operation.
Exception (java.lang)
The root of the exception hierarchy.
FileNotFoundException (java.io)
A specified file name could not be found.
GeneralSecurityException (java.security)
The root of all security exceptions.
IllegalAccessException (java.lang)
The currently executing method does not have access to the definition of a
class that it is attempting to load.
IllegalArgumentException (java.lang)
An invalid or inappropriate argument was passed to a method.
IllegalComponentStateException (java.awt)
An operation was attempted on a component that was in an inappropriate
state.
IllegalMonitorStateException (java.lang)
A thread attempted to notify or wait on another thread that is waiting on an
object that it has not locked.
IllegalStateException (java.lang)
A method was invoked from an improper state.
IllegalThreadStateException (java.lang)
An operation was attempted on a thread that was not in an appropriate state
for that operation to succeed.
IndexOutOfBoundsException (java.lang)
An index into an object such as an array, string, or vector was out of range.
The invalid index could be part of a subrange, specified by a start and end
point or a start point and a length.
InstantiationException (java.lang)
A class could not be instantiated using the newInstance method of class
Class because it is abstract, an array, or an interface.
APPENDIX K java exceptions and errors 743

InterruptedException (java.lang)
While one thread was waiting, another thread interrupted it using the interrupt
method of the Thread class.
InterruptedIOException (java.io)
While one thread was waiting for the completion of an I/O operation, another
thread interrupted it using the interrupt method of the Thread class.
InvalidClassException (java.io)
The serialization run time has detected a problem with a class.
InvalidParameterException (java.security)
An invalid parameter has been passed to a method.
IOException (java.io)
A requested I/O operation could not be completed normally.
JarException (java.util.jar)
A problem occurred while reading from or writing to a JAR file.
MalformedURLException (java.net)
A specified URL does not have an appropriate format or used an unknown
protocol.
NegativeArraySizeException (java.lang)
An attempt was made to instantiate an array that has a negative length.
NoRouteToHostException (java.net)
A path could not be found when attempting to connect a socket to a remote
address and port.
NoSuchElementException (java.util)
An attempt was made to access an element of an empty vector.
NoSuchFieldException (java.lang)
An attempt was made to access a nonexistent field.
NoSuchMethodException (java.lang)
A specified method could not be found.
NullPointerException (java.lang)
A null reference was used where an object reference was needed.
NumberFormatException (java.lang)
An operation was attempted using a number in an illegal format.
ParseException (java.text)
A string could not be parsed according to the specified format.
744 APPENDIX K java exceptions and errors

ProtocolException (java.net)
Some aspect of a network communication protocol was not executed correctly.
RuntimeException (java.lang)
The superclass of all unchecked runtime exceptions.
SecurityException (java.lang)
An operation that violates some kind of security measure was attempted.
SocketException (java.net)
An operation using a socket could not be completed normally.
StringIndexOutOfBoundsException (java.lang)
An index into a String or StringBuffer object is out of range.
TooManyListenersException (java.util)
An event source has registered too many listeners.
UTFDataFormatException (java.io)
An attempt was made to convert a string to or from UTF-8 format, but the
string was too long or the data were not in valid UTF-8 format.
UnknownHostException (java.net)
A specified network host name could not be resolved into a network address.
UnknownServiceException (java.net)
An attempt was made to request a service that the current network connection
does not support.

errors
AbstractMethodError (java.lang)
An attempt was made to invoke an abstract method.
AWTError (java.awt)
A general error indicating that a serious problem has occurred in a class of the
java.awt package.
ClassCircularityError (java.lang)
A circular dependency was found while performing class initialization.
ClassFormatError (java.lang)
The format of the bytecode in a class file is invalid.
Error (java.lang)
The root of the error hierarchy.
APPENDIX K java exceptions and errors 745

ExceptionInInitializerError (java.lang)
An exception has occurred in a static initializer.
IllegalAccessError (java.lang)
An attempt was made to reference a class, method, or variable that was not
accessible.
IncompatibleClassChangeError (java.lang)
An illegal operation was attempted on a class.
InstantiationError (java.lang)
An attempt was made to instantiate an abstract class or an interface.
InternalError (java.lang)
An error occurred in the Java interpreter.
LinkageError (java.lang)
An error occurred while attempting to link classes or resolve dependencies
between classes.
NoClassDefFoundError (java.lang)
The definition of a specified class could not be found.
NoSuchFieldError (java.lang)
A specified field could not be found.
NoSuchMethodError (java.lang)
A specified method could not be found.
OutOfMemoryError (java.lang)
The interpreter has run out of memory and cannot reclaim more through
garbage collection.
StackOverflowError (java.lang)
A stack overflow has occurred in the Java interpreter.
ThreadDeath (java.lang)
The stop method of a thread has caused a thread (but not the interpreter) to
terminate. No error message is printed.
UnknownError (java.lang)
An error has occurred in the Java Virtual Machine (JVM).
UnsatisfiedLinkError (java.lang)
All of the links in a loaded class could not be resolved.
VerifyError (java.lang)
A class failed the bytecode verification procedures.
VirtualMachineError (java.lang)
The superclass of several errors relating to the Java Virtual Machine (JVM).

You might also like