1

NetBeans do not accept my code. Why? See the pic.

vkraemer
  • 9,864
  • 2
  • 30
  • 44
joseph
  • 687
  • 3
  • 12
  • 21

4 Answers4

1

You need to import the annotations you're using.

E.g, import org.whatever.package.contains.ServiceProvider;

tpdi
  • 34,554
  • 11
  • 80
  • 120
1
import {package}.ServiceProvider;
Bertrand Marron
  • 21,501
  • 8
  • 58
  • 94
0

Perhaps you are missing an import. Can you import "ServiceProvider"? It's hard to know for sure without know more about your project setup, but that's my first guess.

FrustratedWithFormsDesigner
  • 26,726
  • 31
  • 139
  • 202
0

You need to change the code from

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

into

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;
import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

Note: You can leverage the Fix Imports item from the Source menu (CTRL-SHIFT-I/Clover-SHIFT-I) to take care of the second one automatically, if you have declared the dependeny between your module and the NetBeans platform Utilities API module

vkraemer
  • 9,864
  • 2
  • 30
  • 44