1

I am using J2ME Polish, compiling for J2ME MIDP 2.1 and using eclipse as my editor. I have been playing around with the Formatter and Code Clean settings for my project to improve code quality. Not matter, how many settings I tweak I cannot get eclipse to stop adding "@Override":

@Override
public void someFunc(String parameters) {
    //TODO Auto-generated method stub

}

How can I stop eclipse adding "@Override" when I click add un-implemented methods?

Edit: I should let others know that J2ME has no annotations.

binarycreations
  • 3,091
  • 6
  • 32
  • 38
  • What's wrong with having `@Override`? I've found it to be useful. – deltaforce2 Jun 10 '11 at 12:26
  • Why do you want to have that removed? – Kaj Jun 10 '11 at 12:26
  • I am compiling for J2ME. It does not have annotations, it uses a smaller VM which has less functionality (e.g. no generics, collections, iterators) and less classes available than the full SE SDK. – binarycreations Jun 10 '11 at 12:29
  • Shouldn't your target jre take care of this? If your target is J2ME, then it should not even have the option to set something that is not available. – Robin Jun 10 '11 at 14:06
  • I am using J2ME Polish which is framework built on top of J2ME. Polish unfortunately does not integrate well with eclipse, I want to use it as my editor and use ant scripts to do the compliation and other hard work. I believe there will be a J2MEPolish plugin for eclipse at some point. – binarycreations Jun 10 '11 at 14:48
  • `it uses a smaller VM which has less functionality` I think you're mistaken. `Override` is a source annotation, not runtime. Whether or not the compiler you're using supports annotations or not, the normal JavaSE compiler discards this annotation. This annotation is not present at runtime (i.e. the JVM won't have any knowledge of it). Just to clear up that language a bit. – searchengine27 Jul 27 '21 at 22:03

2 Answers2

15

Not sure why you want to disable it but here's how you can do it.

Window > Preferences > Java > Code Style 

and uncheck Add '@Override' annotation for new overriding methods.

enter image description here

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • Wow - high quality answer, especially the nice screenshot :) – Bohemian Jun 10 '11 at 12:31
  • My gosh you people are quick! Thanks, I am a bit new to eclipse and now feel embrassed that I missed that. When I try to save these settings I get an Exception, which is not so greate. See - Error: Exception occurred while saving project preferences: /substate_wallet/.settings/org.eclipse.jdt.ui.prefs. Exception occurred while saving project preferences: /substate_wallet/.settings/org.eclipse.jdt.ui.prefs. – binarycreations Jun 10 '11 at 12:32
  • @Graham I'm not sure about that exception but see if this post helps http://stackoverflow.com/questions/954248/cant-save-project-preferences-in-eclipse – Bala R Jun 10 '11 at 12:35
  • Cool, the quick fix was to delete the files and add the project to eclipse again. Again thanks for the quick response. – binarycreations Jun 10 '11 at 12:55
4

In

Java > Editor > Save Actions > Missing Code (Tab)

You can tell java not to add the @Override annotation (this is only if it is missing when you save a file), I'm not sure about when adding unimplemented methods. I would have to ask why you would want this, @Override only adds extra useful information.

mark-cs
  • 4,677
  • 24
  • 32