Rick,

I just confirmed that it *is* an error in the tutorial. Apparently, that tutorial was written way back with NetBeans 7.4:

TemplateRegistration in NB7.4

This screenshot is from my NB 7.4 installation, and as you can see, the /TemplateRegistration/ class used to be in the DataSystems API module. However, by the time NB 8.2 was released, it was moved to the File Templates module. So, a lot of development must have happened to cause the /TemplateRegistration/ class (as well as the rest of the related classes) to be moved into their own module.

I'm betting you could file an issue against that tutorial and whenever someone has time they would fix the information...

-SC

On 2/23/23 3:15 PM, Sean Carrick wrote:

Rick,

I'm going to go with an error in the tutorial. I only say this because all of the tutorials currently need to be reviewed for accuracy and, in my installation of NetBeans 16, when I enter "TemplateRegistration" into the search field of the *Add Module Dependency* dialog, this is what shows up:

TemplateRegistration

Likewise, when I type "NbBundle" in the same search field, I get this:

NbBundle

It could very well be that the tutorial you are working through has not been updated in a while and is still referencing where the classes /used to be/ located. Many changes have happened with the APIs over the decades.

This is why I had said in my last email to "type in" the name of the class you need. It will filter the modules list to only those modules that contain a class with that name.

-SC

On 2/23/23 3:28 AM, Rick Tee wrote:
Redhat 7.9
Netbeans 16
JDK 1.8

From the Netbeans templates tutorial: "Right-click the module in the Projects window, choose Properties, and use the Libraries tab to add dependencies on Datasystems API and Utilities API."

I followed the tutorial twice from scratch the result is the same.

Looking  through the project the file causing errors is: package-info.java. Errors are:

Cannot find symbol class TemplateRegistration
Cannot find symbol class Messages
Package org.netbeans.api.templates does not exist
Package org.openide.util.NbBundle does not exist

Something missing from the installation? or error/s in the tutorial?

Apologies for the replies to wrong address.

On 23/02/2023 04:42, Sean Carrick wrote:
Rick,

You need to set a dependency in each module that uses them on the /File Templates/ and /Base Utilities API/ libraries in order to use them.

Per your compiler output:

/home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:5:
    error: cannot find symbol
    @TemplateRegistration(
       symbol: class TemplateRegistration

You do not have a dependency on the /File Templates/ NetBeans API.

Per your compiler output:

/home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:12:
    error: cannot find symbol
    @Messages(value = "HTMLtemplate_displayName=Empty HTML file")
       symbol: class Messages

You do not have a dependency on the /Base Utilities API/.

When creating application or modules against the NetBeans Platform, you must be specific and explicit in your dependency declarations. To add these dependencies, click on the /Libraries/ node in the Projects window for each of the module projects that need to use these features and select /Add Module Dependency.../ In the field at the top of the dialog, type in "TemplateRegistration" and the list will filter down to only show the /File Templates/ module. Likewise, type in "NbBundle" or "NbBundle.Messages" and the list will filter down to /Base Utilities API/. Add each of those to your module and recompile. You should be fine then.

Also, it helps if, when you are asking for help, you include which version of NetBeans, which version of the JDK, and what build system you are using.

-SC

On 2/21/23 10:52 PM, Rick Tee wrote:
Hi,
I followed the template tutorial: https://netbeans.apache.org/tutorials/nbm-filetemplates.html

When I choose run i get:

warning: [options] bootstrap class path not set in conjunction with -source 1.7 warning: No processor claimed any of these annotations: TemplateRegistration,Messages /home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:15: error: package org.netbeans.api.templates does not exist
import org.netbeans.api.templates.TemplateRegistration;
/home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:16: error: package org.openide.util.NbBundle does not exist
import org.openide.util.NbBundle.Messages;
/home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:5: error: cannot find symbol
@TemplateRegistration(
  symbol: class TemplateRegistration
/home/rick/Projects/AdditionalFileTemplates/src/org/myorg/additionalfiletemplates/package-info.java:12: error: cannot find symbol
@Messages(value = "HTMLtemplate_displayName=Empty HTML file")
  symbol: class Messages
4 errors
1 warning
/usr/lib/apache-netbeans/harness/common.xml:207: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)



Attachment: OpenPGP_0xA195702ECF56996D.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to