This is an automated email from the ASF dual-hosted git repository.
git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new af6574f Automated site publishing by Jenkins build 583
af6574f is described below
commit af6574f522419b7a6fb7f9d06ee14f86d0ed88bd
Author: jenkins <[email protected]>
AuthorDate: Tue Feb 5 17:54:11 2019 +0000
Automated site publishing by Jenkins build 583
---
content/kb/docs/java/annotations-custom.html | 212 ++++++++++++++++-----------
content/kb/docs/java/annotations-lombok.html | 109 ++++++++------
content/kb/docs/java/annotations.html | 56 ++++---
3 files changed, 216 insertions(+), 161 deletions(-)
diff --git a/content/kb/docs/java/annotations-custom.html
b/content/kb/docs/java/annotations-custom.html
index 3c54887..fbdb2fb 100644
--- a/content/kb/docs/java/annotations-custom.html
+++ b/content/kb/docs/java/annotations-custom.html
@@ -5,7 +5,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
- <title>Annotation Processors Support in the NetBeans IDE, Part II: Using
Own Custom Annotation Processors in the IDE</title>
+ <title>Annotations Part II: Using Custom Annotation Processors</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Annotation Processors Support in the
NetBeans IDE, Part II: Using Own Custom Annotation Processors in the IDE -
Apache NetBeans">
<meta name="author" content="Apache NetBeans">
@@ -78,7 +78,7 @@
</section>
<div class='grid-container main-content tutorial'>
- <h1 class="sect0">Annotation Processors Support in the NetBeans
IDE, Part II: Using Own Custom Annotation Processors in the IDE</h1>
+ <h1 class="sect0">Annotations Part II: Using Custom Annotation
Processors</h1>
<div class="sectionbody">
<div class="admonitionblock note">
@@ -97,6 +97,7 @@
<div id="toc" class="toc">
<div id="toctitle"></div>
<ul class="sectlevel1">
+<li><a href="#_requirements">Requirements</a></li>
<li><a
href="#_defining_an_annotation_and_creating_an_annotation_processor">Defining
an Annotation and Creating an Annotation Processor</a></li>
<li><a href="#_using_the_annotation_processor_in_the_ide">Using the Annotation
Processor in the IDE</a></li>
<li><a href="#_see_also">See Also</a></li>
@@ -105,20 +106,7 @@
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
-<p>_Contributed by Jesse Glick, written and maintained by Irina Filippova _</p>
-</div>
-<div class="ulist">
-<ul>
-<li>
-<p><strong>Using Own Custom Annotation Processors in the IDE</strong></p>
-</li>
-</ul>
-</div>
-<div class="imageblock">
-<div class="content">
-<img src="../../../images_www/articles/71/netbeans-stamp-71-72-73.png"
alt="netbeans stamp 71 72 73">
-</div>
-<div class="title">Figure 1. Content on this page applies to the NetBeans IDE
7.0, 7.1, 7.2 and 7.3</div>
+<p>The previous part of the annotations tutorial (<a
href="annotations-lombok.html">Part I: Using Lombok for Custom Annotations</a>)
showed how custom annotations work within NetBeans.</p>
</div>
<div class="paragraph">
<p>In this section of the tutorial, you will learn how to add a self-written
custom annotation processor to a project in the IDE. This tutorial does not
teach you how to write an annotation processor. It explains how to add it to a
NetBeans IDE project.</p>
@@ -129,13 +117,18 @@
<div class="paragraph">
<p>The annotation processor used as the example generates a parent class for
the annotated class. The generated parent class also contains a method that is
called from the annotated class. Follow the instructions below on how to create
and add a custom annotation processor to an IDE’s project.</p>
</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_requirements">Requirements</h2>
+<div class="sectionbody">
<div class="paragraph">
-<p><strong>To complete this tutorial, you need the following software and
resources.</strong></p>
+<p>To complete this tutorial, you need the following software and
resources.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
-<col style="width: 50%;">
-<col style="width: 50%;">
+<col style="width: 75%;">
+<col style="width: 25%;">
</colgroup>
<thead>
<tr>
@@ -145,12 +138,12 @@
</thead>
<tbody>
<tr>
-<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></p></td>
-<td class="tableblock halign-left valign-top"><p class="tableblock">7.0, 7.1,
7.2, 7.3</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.org/download/index.html">NetBeans IDE</a></p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">9.0 or
greater</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java
Development Kit (JDK)</a></p></td>
-<td class="tableblock halign-left valign-top"><p class="tableblock">version 6
or 7</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">version 6
or greater</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="http://code.google.com/p/projectlombok/downloads/list">lombok.jar</a></p></td>
@@ -172,7 +165,7 @@
<p>Choose File > New Project and select the Java Class Library project type
in the Java category. Click Next.</p>
</li>
<li>
-<p>Type * <code>AnnProcessor</code> * as the Project Name and specify a
location for the project. Click Finish.</p>
+<p>Type <code>AnnProcessor</code> as the Project Name and specify a location
for the project. Click Finish.</p>
</li>
</ol>
</div>
@@ -180,7 +173,7 @@
<p>When you click Finish, the IDE creates the class library project and lists
the project in the Projects window.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="3">
<li>
<p>Right-click the AnnProcessor project node in the Projects window and choose
Properties.</p>
</li>
@@ -201,10 +194,10 @@
<p>Right-click the Source Packages node under the AnnProcessor project node
and choose New > Java Package.</p>
</li>
<li>
-<p>Type * <code>ann</code> * for the Package Name and click Finish to create
the new Java package.</p>
+<p>Type <code>ann</code> for the Package Name and click Finish to create the
new Java package.</p>
</li>
<li>
-<p>Repeat the two previous steps to create a Java package named *
<code>proc</code> *.</p>
+<p>Repeat the two previous steps to create a Java package named
<code>proc</code>.</p>
</li>
</ol>
</div>
@@ -215,15 +208,15 @@
<div class="content">
<img src="images/packages.png" alt="packages">
</div>
-<div class="title">Figure 2. The structure of the project for the annotation
processor.</div>
+<div class="title">Figure 1. The structure of the project for the annotation
processor.</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="4">
<li>
<p>Right-click the <code>ann</code> Java package and choose New > Java
class.</p>
</li>
<li>
-<p>Type * <code>Handleable</code> * for the Class Name. Click Finish.</p>
+<p>Type <code>Handleable</code> for the Class Name. Click Finish.</p>
</li>
<li>
<p>Modify the new <code>Handleable.java</code> file to make the following
changes. Save the file.</p>
@@ -234,7 +227,7 @@
<div class="content">
<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">package ann;
-public *@interface* Handleable {
+public @interface Handleable {
}</code></pre>
</div>
@@ -242,27 +235,45 @@ public *@interface* Handleable {
<div class="paragraph">
<p>This is how annotations are declared, and it is quite similar to an
interface declaration. The difference is that the <code>interface</code>
keyword must be preceded with an <code>at</code> sign (@). This annotation is
called <code>Handleable</code> .</p>
</div>
-<div class="paragraph">
-<p><strong>Additional Information.</strong> In annotation declarations, you
can also specify additional parameters, for example, what types of elements can
be annotated, e.g. classes or methods. You do this by adding
<code>@Target(value = {ElementType.TYPE})</code> for classes and
<code>@Target(value = {ElementType.METHOD}).</code> So, the annotation
declaration becomes annotated itself with <em>meta-annotations</em>.</p>
+<div class="admonitionblock tip">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-tip" title="Tip"></i>
+</td>
+<td class="content">
+In annotation declarations, you can also specify additional parameters, for
example, what types of elements can be annotated, e.g. classes or methods. You
do this by adding <code>@Target(value = {ElementType.TYPE})</code> for
classes and <code>@Target(value = {ElementType.METHOD}).</code> So, the
annotation declaration becomes annotated itself with <em>meta-annotations</em>.
+</td>
+</tr>
+</table>
</div>
<div class="paragraph">
<p>You now need to add code for the annotation processor to process the
<code>Handleable</code> annotation.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="7">
<li>
-<p>Right-click the * <code>proc</code> * Java package and choose New > Java
class.</p>
+<p>Right-click the <code>proc</code> Java package and choose New > Java
class.</p>
</li>
<li>
-<p>Type * <code>HandleableProcessor</code> * for the Class Name. Click
Finish.</p>
+<p>Type <code>HandleableProcessor</code> for the Class Name. Click Finish.</p>
</li>
<li>
<p>Modify the <code>HandleableProcessor.java</code> class to add the
following code. Save your changes.</p>
</li>
</ol>
</div>
-<div class="paragraph">
-<p><strong>Note.</strong> The value of <code>@SupportedSourceVersion</code>
(in <strong>bold</strong>) will depend upon the version of the JDK that you are
using and will be either <code>(SourceVersion.RELEASE_7)</code> or
<code>(SourceVersion.RELEASE_6)</code> .</p>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+The value of <code>@SupportedSourceVersion</code> will depend upon the
version of the JDK that you are using and will be either
<code>(SourceVersion.RELEASE_7)</code> or
<code>(SourceVersion.RELEASE_6)</code> .
+</td>
+</tr>
+</table>
</div>
<div class="listingblock">
<div class="content">
@@ -286,7 +297,7 @@ import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
@SupportedAnnotationTypes("ann.Handleable")
-@SupportedSourceVersion(*SourceVersion.RELEASE_7*)
+@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class HandleableProcessor extends AbstractProcessor {
/** public for ServiceLoader */
@@ -373,8 +384,8 @@ public class HandleableProcessor extends AbstractProcessor {
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {
-* public HandleableProcessor() {
- }*
+ public HandleableProcessor() {
+ }
...
}</code></pre>
@@ -385,13 +396,12 @@ public class HandleableProcessor extends
AbstractProcessor {
</div>
<div class="listingblock">
<div class="content">
-<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {*
- *...
-* public boolean process(Set<? extends TypeElement> annotations,
+<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {
+ ...
+ public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
...
}
-*
}</code></pre>
</div>
</div>
@@ -400,30 +410,30 @@ public class HandleableProcessor extends
AbstractProcessor {
</div>
<div class="listingblock">
<div class="content">
-<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {*
- *...
+<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {
+ ...
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {//For each element annotated with the
Handleable annotation
- *for (Element e :
roundEnv.getElementsAnnotatedWith(Handleable.class)) {
+ for (Element e :
roundEnv.getElementsAnnotatedWith(Handleable.class)) {
-*//Check if the type of the annotated element is not a field. If yes, return a
warning*.
+// Check if the type of the annotated element is not a field. If yes, return a
warning.
if (e.getKind() != ElementKind.FIELD) {
processingEnv.getMessager().printMessage(
Diagnostic.Kind.WARNING,
"Not a field", e);
continue;
}
- *//Define the following variables: name and clazz*.**
+ //Define the following variables: name and clazz.
String name = capitalize(e.getSimpleName().toString());
TypeElement clazz = (TypeElement) e.getEnclosingElement();
-*//Generate a source file with a specified class name. *
+//Generate a source file with a specified class name.
try {
JavaFileObject f = processingEnv.getFiler().
createSourceFile(clazz.getQualifiedName() + "Extras");
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
"Creating " + f.toUri());
Writer w = f.openWriter();
-*//Add the content to the newly generated file*.
+//Add the content to the newly generated file.
try {
PrintWriter pw = new PrintWriter(w);
pw.println("package "
@@ -447,8 +457,8 @@ w.close();
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
x.toString());
}
-}*return true;
- * }*
+}return true;
+ }
...
}</code></pre>
</div>
@@ -458,19 +468,19 @@ x.toString());
</div>
<div class="listingblock">
<div class="content">
-<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {*
- *...*
+<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">public class HandleableProcessor extends AbstractProcessor {
+ ...
private static String capitalize(String name) {
-char[] c = name.toCharArray();
-c[0] = Character.toUpperCase(c[0]);
-return new String(c);
-}
-*}</code></pre>
+ char[] c = name.toCharArray();
+ c[0] = Character.toUpperCase(c[0]);
+ return new String(c);
+ }
+}</code></pre>
</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="10">
<li>
<p>Build the project by right-clicking the <code>AnnProcessor</code> project
and choosing Build.</p>
</li>
@@ -490,12 +500,21 @@ return new String(c);
<p>Choose File > New Project and select the Java Application project type
in the Java category. Click Next.</p>
</li>
<li>
-<p>In the Name and Location page, type * <code>Demo</code> * as the Project
Name and specify the project location.</p>
+<p>In the Name and Location page, type <code>Demo</code> as the Project Name
and specify the project location.</p>
</li>
<li>
-<p>Type * <code>demo.Main</code> * in the Create Main Class field. Click
Finish.
-image::images/demo-project-wizard.png[title="Creating the Demo project in the
New Project wizard."]</p>
+<p>Type <code>demo.Main</code> in the Create Main Class field. Click
Finish.</p>
</li>
+</ol>
+</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/demo-project-wizard.png" alt="demo project wizard">
+</div>
+<div class="title">Figure 2. Creating the Demo project in the New Project
wizard.</div>
+</div>
+<div class="olist arabic">
+<ol class="arabic" start="4">
<li>
<p>Open the Project Properties window and confirm that either JDK 6 or JDK 7
are selected as the source/binary format in the Sources panel and that the Java
platform is set to JDK 1.6 or JDK 1.7 in the Libraries panel.</p>
</li>
@@ -508,16 +527,16 @@ image::images/demo-project-wizard.png[title="Creating the
Demo project in the Ne
<div class="content">
<pre class="prettyprint highlight"><code class="language-java"
data-lang="java">package demo;
-*import ann.Handleable;*
+import ann.Handleable;
-public class Main *extends MainExtras* {
+public class Main extends MainExtras {
- *@Handleable
- private String stuff;*
+ @Handleable
+ private String stuff;
- *public static void main(String[] args) {
+ public static void main(String[] args) {
new Main().handleStuff("hello");
- }*
+ }
}</code></pre>
</div>
</div>
@@ -547,30 +566,40 @@ public class Main *extends MainExtras* {
<p>After you save the <code>Main.java</code> code you will see that the IDE
reports multiple compilation errors. This is because the annotation processor
has not been added yet to the project.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="6">
<li>
<p>Right-click the <code>Demo</code> project node in the Projects window,
choose Properties, then select the Libraries category in the Project Properties
window.</p>
</li>
<li>
-<p>In the Compile tab, click Add Project and locate the
<code>AnnProcessor</code> project.
-image::images/demo-properties-compile.png[title="Compile tab in Libraries
category of the project’s Properties window"]</p>
+<p>In the Compile tab, click Add Project and locate the
<code>AnnProcessor</code> project.</p>
</li>
</ol>
</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/demo-properties-compile.png" alt="demo properties compile">
+</div>
+<div class="title">Figure 3. Compile tab in Libraries category of the
project’s Properties window</div>
+</div>
<div class="paragraph">
<p>The Compile tab corresponds to the <code>-classpath</code> option of the
<a
href="http://download.oracle.com/javase/6/docs/technotes/tools/windows/javac.html#options">Java
compiler</a>. Because the annotation processor is a single JAR file that
contains both the annotation definition and the annotation processor, you
should add it to the project’s classpath, which is the Compile tab.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="8">
<li>
<p>Select the Compiling category in the Project Properties window and select
the Enable Annotation Processing and Enable Annotation Processing in Editor
checkboxes.</p>
</li>
<li>
-<p>Specify the annotation processor to run by click the Add button next to the
Annotation Processors text area and typing *
<code>proc.HandleableProcessor</code> * in the Annotation Processor FQN field.
-image::images/demo-processor-fqn.png[title="Annotation Processor FQN dialog
box"]</p>
+<p>Specify the annotation processor to run by click the Add button next to the
Annotation Processors text area and typing *
<code>proc.HandleableProcessor</code> * in the Annotation Processor FQN
field.</p>
</li>
</ol>
</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/demo-processor-fqn.png" alt="demo processor fqn">
+</div>
+<div class="title">Figure 4. Annotation Processor FQN dialog box</div>
+</div>
<div class="paragraph">
<p>The Compiling category in the Project Properties window should look like
the following image.</p>
</div>
@@ -578,20 +607,29 @@ image::images/demo-processor-fqn.png[title="Annotation
Processor FQN dialog box"
<div class="content">
<img src="images/demo-properties-compiling.png" alt="demo properties
compiling">
</div>
-<div class="title">Figure 3. Compiling category in the project’s
Properties window</div>
+<div class="title">Figure 5. Compiling category in the project’s
Properties window</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="10">
<li>
<p>Click OK in the Properties window.</p>
</li>
</ol>
</div>
-<div class="paragraph">
-<p><strong>Note.</strong> In the <code>Main.java</code> file you might still
see compilation errors. This is because the IDE cannot yet find the
<code>MainExtras.java</code> file that declares the <code>handleStuff</code>
method. The <code>MainExtras.java</code> file will be generated after you
build the Demo project for the first time. If Compile On Save is enabled for
you project, the IDE compiled the project when you saved
<code>Main.java</code> .</p>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+In the <code>Main.java</code> file you might still see compilation errors.
This is because the IDE cannot yet find the <code>MainExtras.java</code> file
that declares the <code>handleStuff</code> method. The
<code>MainExtras.java</code> file will be generated after you build the Demo
project for the first time. If Compile On Save is enabled for you project, the
IDE compiled the project when you saved <code>Main.java</code> .
+</td>
+</tr>
+</table>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="11">
<li>
<p>Right-click the Demo project and choose Build.</p>
</li>
@@ -604,7 +642,7 @@ image::images/demo-processor-fqn.png[title="Annotation
Processor FQN dialog box"
<div class="content">
<img src="images/demo-generated-sources.png" alt="demo generated sources">
</div>
-<div class="title">Figure 4. Projects window with Generated Sources</div>
+<div class="title">Figure 6. Projects window with Generated Sources</div>
</div>
<div class="paragraph">
<p>If you review the contents of the generated <code>MainExtras.java</code>
file, you can see that the annotation processor generated the
<code>MainExtras</code> class with the <code>handleStuff</code> method. The
<code>handleStuff</code> method is the one invoked from the annotated
<code>Main.java</code> file.</p>
@@ -622,7 +660,7 @@ public abstract class MainExtras {
</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="12">
<li>
<p>Right-click the Demo project and choose Run.</p>
</li>
@@ -635,10 +673,7 @@ public abstract class MainExtras {
<div class="content">
<img src="images/demo-run.png" alt="demo run">
</div>
-<div class="title">Figure 5. Projects window with Generated Sources</div>
-</div>
-<div class="paragraph">
-<p><a
href="/about/contact_form.html?to=3&subject=Feedback:%20Using%20the%20Annotation%20Processors%20Support%20in%20NetBeans%20IDE">Send
Feedback on This Tutorial</a></p>
+<div class="title">Figure 7. Projects window with Generated Sources</div>
</div>
</div>
</div>
@@ -651,6 +686,9 @@ public abstract class MainExtras {
<div class="ulist">
<ul>
<li>
+<p>The previous part of the annotations tutorial: <a
href="annotations-lombok.html">Part I: Using Lombok for Custom
Annotations</a>).</p>
+</li>
+<li>
<p>Java SE Documentation - <a
href="http://download.oracle.com/javase/6/docs/technotes/guides/language/annotations.html">Annotations</a></p>
</li>
<li>
diff --git a/content/kb/docs/java/annotations-lombok.html
b/content/kb/docs/java/annotations-lombok.html
index 73326e2..864bb23 100644
--- a/content/kb/docs/java/annotations-lombok.html
+++ b/content/kb/docs/java/annotations-lombok.html
@@ -5,7 +5,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
- <title>Annotation Processors Support in the NetBeans IDE, Part I: Using
Project Lombok</title>
+ <title>Annotations, Part I: Using Project Lombok for Custom
Annotations</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Annotation Processors Support in the
NetBeans IDE, Part I: Using Project Lombok - Apache NetBeans">
<meta name="author" content="Apache NetBeans">
@@ -78,7 +78,7 @@
</section>
<div class='grid-container main-content tutorial'>
- <h1 class="sect0">Annotation Processors Support in the NetBeans
IDE, Part I: Using Project Lombok</h1>
+ <h1 class="sect0">Annotations, Part I: Using Project Lombok for
Custom Annotations</h1>
<div class="sectionbody">
<div class="admonitionblock note">
@@ -97,6 +97,7 @@
<div id="toc" class="toc">
<div id="toctitle"></div>
<ul class="sectlevel1">
+<li><a href="#_requirements">Requirements</a></li>
<li><a href="#_creating_a_new_java_project">Creating a New Java
project</a></li>
<li><a
href="#_enabling_custom_annotations_lombok_jar_for_the_project">Enabling Custom
Annotations (lombok.jar) for the Project</a></li>
<li><a href="#_writing_an_application_using_lombok_custom_annotations">Writing
an Application Using Lombok Custom Annotations</a></li>
@@ -105,29 +106,21 @@
</div>
<div id="preamble">
<div class="sectionbody">
-<div class="imageblock">
-<div class="content">
-<img src="images/netbeans-stamp-80-74-73.png" alt="netbeans stamp 80 74 73">
-</div>
-<div class="title">Figure 1. Content on this page applies to the NetBeans IDE
7.2, 7.3, 7.4 and 8.0</div>
-</div>
-<div class="ulist">
-<ul>
-<li>
-<p><strong>Using Project Lombok for Custom Annotations</strong></p>
-</li>
-</ul>
-</div>
<div class="paragraph">
<p>To demonstrate how custom annotations work inside the NetBeans IDE, we will
use Project Lombok, which provides a convenient way of automatically generating
several Java code elements, such as getters, setters, constructors and others.
For more information about its features, visit the <a
href="http://projectlombok.org/">Project Lombok's website</a>. However, keep in
mind that Project Lombok includes some features that might not work in all
development environments.</p>
</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_requirements">Requirements</h2>
+<div class="sectionbody">
<div class="paragraph">
-<p><strong>To complete this tutorial, you need the following software and
resources.</strong></p>
+<p>To complete this tutorial, you need the following software and
resources.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
-<col style="width: 50%;">
-<col style="width: 50%;">
+<col style="width: 75%;">
+<col style="width: 25%;">
</colgroup>
<thead>
<tr>
@@ -137,8 +130,8 @@
</thead>
<tbody>
<tr>
-<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></p></td>
-<td class="tableblock halign-left valign-top"><p class="tableblock">7.2, 7.3,
7.4, 8.0</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.org/download/index.html">NetBeans IDE</a></p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">9.0 or
later</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java
Development Kit (JDK)</a></p></td>
@@ -161,30 +154,35 @@
<div class="olist arabic">
<ol class="arabic">
<li>
-<p>Choose <strong>File > New Project</strong> from the main menu to open
the New Project wizard.</p>
+<p>Choose <em>File > New Project</em> from the main menu to open the New
Project wizard.</p>
</li>
<li>
<p>Select the Java Application project type in the Java category. Click
Next.</p>
</li>
<li>
-<p>In the Name and Location page of the wizard, type * <code>TestAnn</code> *
as the project name.</p>
+<p>In the Name and Location page of the wizard, type <code>TestAnn</code> as
the project name.</p>
</li>
<li>
-<p>Type * <code>testann.TestBooks</code> * in the Create Main Class field to
replace the default class name. Click Finish.
-image::images/newproj.png[title="Creating a new Java project in the NetBeans
IDE"]</p>
+<p>Type <code>testann.TestBooks</code> in the Create Main Class field to
replace the default class name. Click Finish.</p>
</li>
</ol>
</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/newproj.png" alt="newproj">
+</div>
+<div class="title">Figure 1. Creating a new Java project in the NetBeans
IDE</div>
+</div>
<div class="paragraph">
<p>When you click Finish, the IDE creates the Java application project and
opens the <code>TestBooks.java</code> class in the editor. You can see that
the new project is now visible in the Projects window and that the
<code>TestBooks.java</code> class is in the <code>testann</code> package
under the Source Packages node.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="5">
<li>
<p>Right-click the <code>testann</code> package node in the Projects window
and choose New > Java class.</p>
</li>
<li>
-<p>Type * <code>MyBooks</code> * for the Class Name and confirm that the class
will be created in the <code>testann</code> package. Click Finish.</p>
+<p>Type <code>MyBooks</code> for the Class Name and confirm that the class
will be created in the <code>testann</code> package. Click Finish.</p>
</li>
</ol>
</div>
@@ -192,7 +190,7 @@ image::images/newproj.png[title="Creating a new Java
project in the NetBeans IDE
<p>When you click Finish the IDE opens the new class in the editor.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="7">
<li>
<p>In the source editor, add the following three fields to
<code>MyBooks.java</code> .</p>
</li>
@@ -211,14 +209,23 @@ public class MyBooks {
</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="8">
<li>
<p>Place your insert cursor in the class declaration and press Ctrl-Space to
invoke the editor’s code completion support.</p>
</li>
<li>
-<p>Select <code>MyBooks (int year, String title, String author) -
generate</code> in the code completion list to generate a constructor for
<code>MyBooks.java</code> .
-image::images/generate-constructor.png[title="Code completion to generate
constructor"]</p>
+<p>Select <code>MyBooks (int year, String title, String author) -
generate</code> in the code completion list to generate a constructor for
<code>MyBooks.java</code> .</p>
</li>
+</ol>
+</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/generate-constructor.png" alt="generate constructor">
+</div>
+<div class="title">Figure 2. Code completion to generate constructor</div>
+</div>
+<div class="olist arabic">
+<ol class="arabic" start="10">
<li>
<p>Save your changes.</p>
</li>
@@ -253,16 +260,21 @@ image::images/properties1.png[title="Libraries category
in Properties window"]</
<p>The resources added on the Compile tab correspond to the
<code>-classpath</code> option of the <a
href="http://download.oracle.com/javase/6/docs/technotes/tools/windows/javac.html#options">Java
compiler</a>. As <code>lombok.jar</code> is a single JAR file that contains
both annotation definitions and annotation processors, you should add it to the
project’s classpath, which is the Compile tab.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="5">
<li>
<p>Choose the Compiling category in the Project Properties window.</p>
</li>
<li>
-<p>Confirm that the Enable Annotation Processing checkbox is selected (it is
enabled by default) and select the Enable Annotation Processing in Editor
checkbox.
-image::images/properties2.png[title="Compiling category in Properties
window"]</p>
+<p>Confirm that the Enable Annotation Processing checkbox is selected (it is
enabled by default) and select the Enable Annotation Processing in Editor
checkbox.</p>
</li>
</ol>
</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/properties2.png" alt="properties2">
+</div>
+<div class="title">Figure 3. Compiling category in Properties window</div>
+</div>
<div class="paragraph">
<p>The Enable Annotation Processing checkbox enables annotation processing
while building and compiling your project. If the checkbox is not selected, the
<code>-proc:none</code> option is passed to the Java compiler, and
compilation takes places without any annotation processing. So, if you want to
process annotations in your code, the Enable Annotation Processing checkbox
must be selected.</p>
</div>
@@ -270,7 +282,7 @@ image::images/properties2.png[title="Compiling category in
Properties window"]</
<p>By selecting the Enable Annotation Processing in Editor checkbox, you make
annotation processing results visible in the editor. Any additional artifacts
that are generated by annotation processors (classes, methods, fields, etc.)
become visible in the IDE Editor and available in code completion, Navigator,
GoTo Type, Find usages, and others.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="7">
<li>
<p>Click OK in the Project Properties window and return to the
<code>MyBooks.java</code> file.</p>
</li>
@@ -283,7 +295,7 @@ image::images/properties2.png[title="Compiling category in
Properties window"]</
<div class="content">
<img src="images/projects-window.png" alt="projects window">
</div>
-<div class="title">Figure 2. Libraries node in Projects window</div>
+<div class="title">Figure 4. Libraries node in Projects window</div>
</div>
</div>
</div>
@@ -301,13 +313,18 @@ image::images/properties2.png[title="Compiling category
in Properties window"]</
<p>To learn more about what annotations are supported by Project Lombok, refer
to the Lombok <a href="http://projectlombok.org/features/index.html">Features
Overview</a>.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="2">
<li>
-<p>Click the hint in the editor’s left margin and add import for
<code>lombok.Data</code> .
-image::images/import-lombok.png[title="Hint in editor to import lombok"]</p>
+<p>Click the hint in the editor’s left margin and add import for
<code>lombok.Data</code> .</p>
</li>
</ol>
</div>
+<div class="imageblock">
+<div class="content">
+<img src="images/import-lombok.png" alt="import lombok">
+</div>
+<div class="title">Figure 5. Hint in editor to import lombok</div>
+</div>
<div class="paragraph">
<p>The resulting code in the Editor should look like the example below.</p>
</div>
@@ -340,13 +357,13 @@ public class MyBooks {
<div class="content">
<img src="images/nav.png" alt="nav">
</div>
-<div class="title">Figure 3. Navigator window showing project members</div>
+<div class="title">Figure 6. Navigator window showing project members</div>
</div>
<div class="paragraph">
<p>You can also invoke the code completion window (Ctrl-Space) and see that
the generated artifacts are available for picking them. Now, let’s see
that the project compiles and the generated artifacts can be called from other
parts of the program.</p>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="3">
<li>
<p>Open the <code>TestBooks.java</code> file with the <em>main</em> method
and add the following code (in bold) to create a new object of the
<code>MyBooks</code> class.</p>
</li>
@@ -365,7 +382,7 @@ public class TestBooks {
</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="4">
<li>
<p>Add the following code to print out the values of the <code>books</code>
variable.</p>
</li>
@@ -388,7 +405,7 @@ public class TestBooks {
</div>
</div>
<div class="olist arabic">
-<ol class="arabic">
+<ol class="arabic" start="5">
<li>
<p>Save your changes.</p>
</li>
@@ -404,7 +421,7 @@ public class TestBooks {
<div class="content">
<img src="images/output.png" alt="output">
</div>
-<div class="title">Figure 4. Output window after running the application</div>
+<div class="title">Figure 7. Output window after running the application</div>
</div>
<div class="paragraph">
<p>You can see that the artifacts generated by the Lombok annotation processor
are accessible from other parts of the program.</p>
@@ -417,11 +434,13 @@ public class TestBooks {
<div class="ulist">
<ul>
<li>
+<p><a href="annotations-custom.html">Part II: Using Own Custom Annotation
Processor in the IDE</a></p>
+</li>
+<li>
<p>Java SE Documentation - <a
href="http://download.oracle.com/javase/6/docs/technotes/guides/language/annotations.html">Annotations</a></p>
</li>
<li>
-<p>Java SE Tutorial - <a
href="http://download.oracle.com/javase/tutorial/java/javaOO/annotations.html">Annotations</a>
-<a
href="/about/contact_form.html?to=3&subject=Feedback:%20Using%20the%20Annotation%20Processors%20Support%20in%20NetBeans%20IDE">Send
Feedback on This Tutorial</a></p>
+<p>Java SE Tutorial - <a
href="http://download.oracle.com/javase/tutorial/java/javaOO/annotations.html">Annotations</a></p>
</li>
</ul>
</div>
diff --git a/content/kb/docs/java/annotations.html
b/content/kb/docs/java/annotations.html
index 1dce988..fd9d965 100644
--- a/content/kb/docs/java/annotations.html
+++ b/content/kb/docs/java/annotations.html
@@ -97,23 +97,14 @@
<div id="toc" class="toc">
<div id="toctitle"></div>
<ul class="sectlevel1">
+<li><a href="#_requirements">Requirements</a></li>
<li><a href="#_introduction">Introduction</a></li>
<li><a
href="#_map_of_javac_options_and_ide_commands_for_annotation_processing">Map of
javac Options and IDE Commands for Annotation Processing</a></li>
-<li><a href="#_next_steps">Next Steps</a></li>
</ul>
</div>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
-<p><em>Sample contributed by Jesse Glick.</em></p>
-</div>
-<div class="imageblock">
-<div class="content">
-<img src="images/netbeans-stamp-80-74-73.png" alt="netbeans stamp 80 74 73">
-</div>
-<div class="title">Figure 1. Content on this page applies to the NetBeans IDE
7.2, 7.3, 7.4 and 8.0</div>
-</div>
-<div class="paragraph">
<p>This two-part tutorial demonstrates how you can attach annotation
processors to a project and use them while working on your code in the IDE.
NetBeans IDE includes built-in support for custom annotation processors. Now
you can conveniently specify annotation processors to run with your project and
see the results of annotation processing directly in the Java Editor through
code completion and navigation.</p>
</div>
<div class="paragraph">
@@ -122,13 +113,18 @@
<div class="paragraph">
<p>The <a href="annotations-custom.html">second part of the tutorial</a>
provides explanations of how to add a self-written annotation processor to a
project. The sample code for this part of the tutorial is contributed by Jesse
Glick.</p>
</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_requirements">Requirements</h2>
+<div class="sectionbody">
<div class="paragraph">
-<p><strong>To complete this tutorial, you need the following software and
resources.</strong></p>
+<p>To complete this tutorial, you need the following software and
resources.</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
-<col style="width: 50%;">
-<col style="width: 50%;">
+<col style="width: 75%;">
+<col style="width: 25%;">
</colgroup>
<thead>
<tr>
@@ -138,8 +134,8 @@
</thead>
<tbody>
<tr>
-<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></p></td>
-<td class="tableblock halign-left valign-top"><p class="tableblock">7.2, 7.3,
7.4, 8.0</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="https://netbeans.apache.org/download/index.html">NetBeans IDE</a></p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">9.0 or
later</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a
href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java
Development Kit (JDK)</a></p></td>
@@ -182,14 +178,23 @@
<div class="paragraph">
<p>As mentioned above, in Java SE 6 javac, annotation processing was
incorporated as an integral functionality of the Java compiler. The compiler
automatically searches for annotation processors by default at user class path
(unless annotation processing is explicitly disabled). In addition, the search
path or a path to particular annotation processors can be specified by using
javac options. In the table below, you can see a map of the javac options
related to annotation processing and [...]
</div>
-<div class="paragraph">
-<p><strong>Note.</strong> In the IDE, the annotation processing options for
all Java application with the exception of NetBeans platform applications are
specified in the Project Properties window. To open the project’s
Properties window window, right-click your project and choose Properties.</p>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+In the IDE, the annotation processing options for all Java application with
the exception of NetBeans platform applications are specified in the Project
Properties window. To open the project’s Properties window window,
right-click your project and choose Properties.
+</td>
+</tr>
+</table>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
-<col style="width: 33.3333%;">
-<col style="width: 33.3333%;">
-<col style="width: 33.3334%;">
+<col style="width: 14.2857%;">
+<col style="width: 42.8571%;">
+<col style="width: 42.8572%;">
</colgroup>
<thead>
<tr>
@@ -232,13 +237,9 @@
</tbody>
</table>
<div class="paragraph">
-<p> </p>
-</div>
-</div>
+<p>
+== Next Steps</p>
</div>
-<div class="sect1">
-<h2 id="_next_steps">Next Steps</h2>
-<div class="sectionbody">
<div class="paragraph">
<p>Read the following parts of the tutorial to learn how to use annotations in
the IDE.</p>
</div>
@@ -252,9 +253,6 @@
</li>
</ul>
</div>
-<div class="paragraph">
-<p><a
href="/about/contact_form.html?to=3&subject=Feedback:%20Using%20the%20Annotation%20Processors%20Support%20in%20the%20NetBeans%20IDE">Send
Feedback on This Tutorial</a></p>
-</div>
</div>
</div>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists