Getting improper compilation error for @Override annotation

537 Views Asked by At

I have one interface SysPropHelper

package com.byteslounge.spring.tx.sys;

public interface SysPropHelper {

    void initSysProp();

}

and one class (SysPropHelperImpl) which implements this interface

package com.byteslounge.spring.tx.sys;

public class SysPropHelperImpl implements SysPropHelper {

    public void initSysProp() {

        System.out.println("From initSysProp method");
    }

}

Both are in the same package. From main method I just called the initSysProp() method and I got the desired result and the output is

From initSysProp method

Still now everything is fine.

But when I annotated initSysProp() method of SysPropHelperImpl class with @Override annotation, surprisingly I got the below mentioned error

The method initSysProp() of type SysPropHelperImpl must override a superclass method

Code after annotated initSysProp() method with @Override annoation

package com.byteslounge.spring.tx.sys;

public class SysPropHelperImpl implements SysPropHelper {

    @Override
    public void initSysProp() {

        System.out.println("From initSysProp method");
    }

}

Trust me, I don't know why I am getting this error.I have restarted the Eclispe,restarted my machine, but no luck.

I am using Eclipse Luna and JDK version is 1.7. If any one has any clue to fix this, please guide me.

The java compiler level and JRE are 1.7 in eclipse.

enter image description here

enter image description here

enter image description here

enter image description here

0

There are 0 best solutions below