How to resolve Must Override a Superclass Method Errors after importing a project into Eclipse

0 votes

Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, causing the error The method must override a superclass method.

list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

    //These arguments have their correct names
    public void onCreateContextMenu(ContextMenu menu, View v, 
                                    ContextMenuInfo menuInfo) {                 
    }

});

will be initially populated like this:

list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

    //This methods arguments were not automatically provided    
    public void onCreateContextMenu(ContextMenu arg1, View arg2,
                                    ContextMenuInfo arg3) {
    }

});

The odd thing is, if I remove my code, and have Eclipse automatically recreate the method, it uses the same argument names I already had, so I don't really know where the problem is, other then it auto-formatting the method for me.

This becomes quite a pain having to manually recreate ALL my overridden methods by hand. PLease help me to fix this.

Is it due to the way I am formatting the methods, which are inside an argument of another method

Jan 10, 2019 in Java by Sushmita
• 6,910 points
3,915 views

1 answer to this question.

0 votes
Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).

Go to your project/IDE preferences and set the Java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from Eclipse.
answered Jan 10, 2019 by developer_1
• 3,320 points

Related Questions In Java

0 votes
1 answer

How to call a method after a delay in Android using Java?

final Handler handler = new Handler(); handler.postDelayed(new Runnable() ...READ MORE

answered Jun 11, 2018 in Java by Akrati
• 3,190 points
5,081 views
+4 votes
11 answers

How to import a jar file in Eclipse?

Click on File > Import. The Import ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,120 points
352,386 views
0 votes
2 answers

How to convert a JSON String into Object in Java?

You could probably check out Google's Gson: ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 59,230 points
3,045 views
0 votes
2 answers

How to convert a java string into byte array

Try using String.getBytes(). It returns a byte[] ...READ MORE

answered Aug 22, 2019 in Java by Sirajul
• 59,230 points
1,160 views
0 votes
1 answer

Error:The method must override a superclass method after importing a project into Eclipse

Hello @kartik, This problem happened when I imported ...READ MORE

answered Jul 28, 2020 in Java by Niroj
• 82,880 points
1,591 views
0 votes
2 answers

Ho do I Iterate through a HashMap which contains duplicate values

for (Map.Entry<String, String> item : params.entrySet()) { ...READ MORE

answered Jul 24, 2018 in Java by samarth295
• 2,220 points
4,826 views
0 votes
2 answers

Performing Iteration over each entry in a 'Map'

In Java 8 you can do it ...READ MORE

answered Oct 24, 2018 in Java by Sushmita
• 6,910 points
801 views
0 votes
2 answers
0 votes
2 answers

How do I convert an input stream into a byte array

You could probably try this if you ...READ MORE

answered Aug 29, 2019 in Java by Sirajul
• 59,230 points
3,369 views
0 votes
2 answers

How can I invoke a method when the method name is in the form of a given string?

You could probably use method invocation from reflection: Class<?> ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 59,230 points
2,593 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP