Force warning when class is not closed

When I work with IO classes like java.util.Scanner or, Eclipse displays a warning Resource leak: 'suchAndSuch' is never closed. How can I make Eclipse display this warning for my own class when it is not closed?

What I want to know is if there is an Interface or something I need to implement to make my class be treated like the IO classes, so that it’s independent of any one IDE, e.g. the command line javac also displays a warning when a resource isn’t closed.


Eclipse gives warning “never closed” for any class which implements

class X implements Closeable {
    public void close() throws IOException {

    public static void main(String[] args) throws IOException {
        X x = new X(); <-- Eclipse warning

Source: stackoverflow