Hai’s Blog

November 22, 2007

Java Exceptions List

Filed under: Programming — Hai @ 9:20 pm

Sometimes when I write Java code and need to throw an exception, I vaguely remember the exception’s name, but not to the exact spelling. For that, I am compiling this on-going list of exceptions to remind myself.

AclNotFoundException
ActivationException
AlreadyBoundException
ApplicationException
ArithmeticException
ArrayOutOfBoundsException
AssertionException
AWTException
BackingStoreException
BadLocationException
BatchUpdateException
CertificateException
ChangedCharSetException
CharacterCodingException
CharConversionException
ClassNotFoundException
CloneNotSupportedException
ClosedChannelException
DataFormatException
DestroyFailedException
EOFException
ExpandVetoException
FileLockInterruptionException
FileNotFoundException
FontFormatException
GeneralSecurityException
GSSException
IIOException
IllegalAccessException
IllegalArgumentException
IllegalStateException
InstantiationException
InterruptedException
InterruptedIOException
IntrospectionException
InvalidMidiDataException
InvalidPreferencesFormatException
InvocationTargetException
IOException
LastOwnerException
LineUnavailableException
MalformedURLException
MidiUnavailableException
MimeTypeParseException
NamingException
NegativeArraySizeException
NoninvertibleTransformException
NoSuchElement
NoSuchFieldException
NoSuchMethodException
NotBoundException
NotOwnerException
NumberFormatException
ObjectStreamException
ParseException
ParserConfigurationException
PrinterException
PrintException
PrivilegedActionException
PropertyVetoException
ProtocolException
RefreshFailedException
RemarshalException
RemoteException
RuntimeException
SAXException
ServerNotActiveException
SocketException
SQLException
SQLWarning
SSLException
SyncFailedException
TooManyListenersException
TransformerException
UnknownHostException
UnknownServiceException
UnsupportedAudioFileException
UnsupportedCallbackException
UnsupportedEncodingException
UnsupportedFlavorException
UnsupportedLookAndFeelException
UnsupportedOperationException
URISyntaxException
UserException
UTFDataFormatException
XAException
ZipException

20 Comments »

  1. That’s helped. Thanks.

    Comment by unr303 — November 29, 2007 @ 2:42 pm

  2. really it helps lot for me. Is any other exception other than in ur list. if so please update.

    Thanks and keep updating…

    Comment by Bala — January 25, 2008 @ 7:14 am

  3. Thanks for the list. Add NoSuchElement (used with collections) to your list.

    Comment by Mark — September 17, 2008 @ 7:38 pm

  4. some more….
    NumberFormatException
    ArrayOutOfBoundsException
    NegativeArraySizeException

    Comment by Sphere — October 16, 2008 @ 12:38 am

  5. Thank you Sphere, I have added your suggestions. For others: please send me update via comment and I will try my best to keep the list up-to-date.

    Comment by wuhrr — October 16, 2008 @ 4:16 pm

  6. Thanks

    Comment by Rubens Mariuzzo — October 16, 2008 @ 6:15 pm

  7. I’m working on a “Game of Life” program, and I can’t decide what exception to use for a certain method. Here’s the code:

    switch(direction)
    {
    case LEFT:
    // Determine if the pointer cell has any left neighbors
    return (cells[pointer.x-1][pointer.y].state == true);
    case UP:
    // Determine if the pointer cell has any up neighbors
    return (cells[pointer.x][pointer.y-1].state == true);
    case RIGHT:
    // Determine if the pointer cell has any right neighbors
    return (cells[pointer.x+1][pointer.y].state == true);
    case DOWN:
    // Determine if the pointer cell has any right neighbors
    return (cells[pointer.x][pointer.y+1].state == true);
    default:
    System.err.println(“Invalid value for direction”);
    throw new [Exception here];
    return false;
    }

    Comment by TC0G — January 2, 2009 @ 6:50 pm

  8. Can you help me? Thanks.

    Comment by TC0G — January 2, 2009 @ 6:51 pm

  9. IllegalArgumentException…also a common one.

    Comment by Stan — January 5, 2009 @ 11:33 pm

  10. To TC0G: I suggest UnsupportedOperationException, or you can define your own exception.

    Comment by Hai — January 6, 2009 @ 4:41 pm

  11. Stan: Thank you for your excellent suggestion. I have added IllegalArgumentException to the list.

    Comment by Hai — January 6, 2009 @ 4:45 pm

  12. How about UnsupportedOperationException?

    Comment by Hai — January 6, 2009 @ 4:47 pm

  13. It helped a lot. tks!

    Comment by Marcelo — July 29, 2009 @ 7:42 pm

  14. ArithmeticException?

    Comment by egasimus — August 29, 2009 @ 2:53 pm

  15. @egasimus:I updated my post with your suggestion. Thanks.

    Comment by Hai — September 3, 2009 @ 9:33 pm

  16. Where’s the AssertionException & the URLBlockException ?

    But anyways thanks – it helped !

    Comment by RR — September 22, 2009 @ 5:43 am

  17. @RR – I added AssertionException, but did not find any info on URLBlockException. Did you misspelled it?

    Comment by Hai — September 22, 2009 @ 9:32 pm

  18. can someone create a short program with me.. like calculator

    Comment by ;erwin ualat — November 10, 2009 @ 6:24 am

  19. Helpful list.

    One you missed:
    IllegalStateException

    Also, you might want to consider dividing the list into checked and unchecked exceptions (http://java.sun.com/docs/books/tutorial/essential/exceptions/catchOrDeclare.html).

    Comment by Matt — November 23, 2009 @ 4:48 pm

  20. Thank you Matt, I have added IllegalStateException to the list

    Comment by Hai — November 24, 2009 @ 6:08 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.