Take the 2-minute tour ×

Is there anything like .NET's NotImplementedException in Java?

share|improve this question
add comment

4 Answers

up vote 227 down vote accepted

Commons Lang has it. Or you could throw an UnsupportedOperationException.

share|improve this answer
It appears that NotImplementedException has been removed from Commons Lang 3.0. –  Michael Younkin Aug 19 '11 at 15:17
I think since the UnsupportedOperationException is part of the collections framework, it should only be used if it is used in the conext of Collections. Otherwise a RuntimeException should be used. docs.oracle.com/javase/7/docs/technotes/guides/collections/… –  L.Butz May 16 '12 at 14:06
@LeonardButz It comes from java.lang: docs.oracle.com/javase/1.5.0/docs/api/java/lang/… –  Ravi Wallau May 24 '12 at 19:25
@RaviWallau I saw this: docs.oracle.com/javase/7/docs/api/java/lang/… There stands that this class is a member of the Java Collection Framework. –  L.Butz Jul 11 '12 at 10:56
@LeonardButz You are right. Not sure why that is. –  Ravi Wallau Jul 14 '12 at 1:54
add comment

I think the UnsupportedOperationException is what you are looking for.


share|improve this answer
I say it is something quite different. The NIE also tells it may not implemented yet, where the UOE says me it never will... –  Dykam Feb 24 '10 at 21:01
@Dykam, then wouldn't it be a NotImplementedYetException? –  Yishai Feb 24 '10 at 21:06
@Dykam: new UnsupportedOperationException("Not implemented yet") - happy? –  Michael Borgwardt Feb 24 '10 at 21:08
I didn't mean it was worse, just had a different use case. –  Dykam Feb 25 '10 at 5:46
new UnsupportedOperationException("Not implemented yet") is an awesome idea! :) in lang3 for some reason I don't have NotImplementedException so this is a great solution –  ufk Jul 6 '11 at 9:35
show 2 more comments

You could do it yourself (thats what I did) - in order to not be bothered with exception handling, you simply extend the RuntimeException, your class could look something like this:

public class NotImplementedException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public NotImplementedException(){}

You could extend it to take a message - but if you use the method as I do (that is, as a reminder, that there is still something to be implemented), then usually there is no need for additional messages.

I dare say, that I only use this method, while I am in the process of developing a system, makes it easier for me to not lose track of which methods are still not implemented properly :)

Cheers, Ready4Android

share|improve this answer
I like this solution the best because it's easy to have a special error handler for it, it's easy to search for it by finding all references to the NotImplementedException constructor, and it's just a few lines of code. But it is a bit inconvenient to have to declare a new class with its own file. –  Derrick Coetzee Mar 31 '12 at 13:19
I agree. This is better than the use of UnsupportedOperationException in my opinion. Now, if only Java would add this to the common library of exceptions! –  crush Sep 5 '13 at 12:50
add comment

No there isn't and it's probably not there, because there are very few valid uses for it. I would think twice before using it. Also, it is indeed easy to create yourself.

Please refer to this discussion about why it's even in .NET.

I guess UnsupportedOperationException comes close, although it doesn't say the operation is just not implemented, but unsupported even. That could imply no valid implementation is possible. Why would the operation be unsupported? Should it even be there? Interface segregation or Liskov substitution issues maybe?

If it's work in progress I'd go for ToBeImplementedException, but I've never caught myself defining a concrete method and then leave it for so long it makes it into production and there would be a need for such an exception.

share|improve this answer
add comment

Your Answer


