| <!doctype html> |
| <html class="no-js" lang="en" dir="ltr"> |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| <title>Overview of JDK 8 Support in NetBeans IDE</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <meta name="description" content="Overview of JDK 8 Support in NetBeans IDE - Apache NetBeans"> |
| <meta name="author" content="Apache NetBeans"> |
| <meta name="description" content="Overview of JDK 8 Support in NetBeans IDE - Apache NetBeans"> |
| <meta name="keywords" content="Apache NetBeans, Tutorials, Overview of JDK 8 Support in NetBeans IDE"> |
| <meta name="generator" content="Apache NetBeans"> |
| <link rel="stylesheet" href="../../../../../../_/css/font-awesome.min.css"> |
| <link rel="alternate" type="application/atom+xml" title="Apache NetBeans Blog" href="https://netbeans.apache.org/blogs/atom" /> |
| <link rel="stylesheet" href="../../../../../../_/css/highlightjs/default.min.css"> |
| <link rel="stylesheet" href="../../../../../../_/css/netbeans.css"> |
| <link rel="apple-touch-icon" sizes="180x180" href="../../../../../../_/images/fav/apple-touch-icon.png"> |
| <link rel="icon" type="image/png" sizes="32x32" href="../../../../../../_/images/fav/favicon-32x32.png"> |
| <link rel="icon" type="image/png" sizes="16x16" href="../../../../../../_/images/fav/favicon-16x16.png"> |
| <link rel="manifest" href="../../../../../../_/images/fav/site.webmanifest"> |
| <link rel="mask-icon" href="../../../../../../_/images/fav/safari-pinned-tab.svg" color="#5bbad5"> |
| <meta name="msapplication-TileColor" content="#ffc40d"> |
| <meta name="theme-color" content="#ffffff"> |
| <link href="../../../../../../_/css/font-open-sans.css" rel="stylesheet"> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| </head> |
| <body> |
| <div class="title-bar" data-responsive-toggle="responsive-menu" data-hide-for="medium"> |
| <button type="button" data-toggle="responsive-menu"><i style='font-size: 32px; color: #fff; padding: 8px' class='fa fa-bars'></i></button> |
| <div class="title-bar-title">Apache NetBeans</div> |
| </div> |
| <div class="top-bar" id="responsive-menu"> |
| <div class='top-bar-left'> |
| <a class='title' href="../../../../../../index.html"><img src='../../../../../../_/images/apache-netbeans.svg' style='padding: 8px; height: 48px;'> Apache NetBeans</a> |
| </div> |
| <div class="top-bar-right"> |
| <ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown"> |
| <li> <input id="search-input" type="text" placeholder="Search the docs"> </li> |
| <li> <a href="../../../../../../front/main/community">Community</a> </li> |
| <li> <a href="../../../../../../front/main/participate">Participate</a> </li> |
| <li> <a href="../../../../../../front/main/blogs">Blog</a></li> |
| <li> <a href="../../../../../../front/main/help">Get Help</a> </li> |
| <li> <a href="https://plugins.netbeans.apache.org/">Plugins</a> </li> |
| <li> <a href="../../../../../../front/main/download">Download</a> </li> |
| </ul> |
| </div> |
| </div> |
| |
| <!-- src/templates/news --> |
| <section class="hero news alternate"> |
| <div class='grid-container'> |
| <div class='cell'> |
| <div class="annotation">Latest release</div> |
| <h1>Apache NetBeans 27</h1> |
| <p><a class="button success" href="../../../../../../front/main/download/nb27">Download</a></p> |
| </div> |
| </div> |
| </section> |
| <div class='grid-container main-content tutorial'> |
| <article class="doc"> |
| <h1 class="sect0">Overview of JDK 8 Support in NetBeans IDE</h1> |
| <div class="sectionbody"> |
| <div class="admonitionblock note"> |
| <table> |
| <tbody><tr> |
| <td class="icon"><i class="fa icon-note" title="Note"></i></td> |
| <td class="content">This tutorial needs a review. |
| You can <a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/kb/docs/java/javase-jdk8.adoc" title="Edit this tutorial in github">edit it in GitHub </a> |
| following these <a href="../../../../../../tutorial/main/kb/docs/contributing">contribution guidelines.</a></td> |
| </tr></tbody> |
| </table> |
| </div> |
| </div> |
| <div id="toc" class="toc"> |
| <div id="toctitle"></div> |
| <ul class="sectlevel1"> |
| <li><a href="#_enabling_jdk_8_support_in_netbeans_ide">Enabling JDK 8 Support in NetBeans IDE</a></li> |
| <li><a href="#_configuring_a_project_to_use_jdk_8">Configuring a Project to use JDK 8</a></li> |
| <li><a href="#_using_compact_profiles_support">Using Compact Profiles Support</a></li> |
| <li><a href="#_using_lambda_expressions_support">Using Lambda Expressions Support</a></li> |
| <li><a href="#_using_repeating_annotations_support">Using Repeating Annotations Support</a></li> |
| <li><a href="#_see_also">See Also</a></li> |
| </ul> |
| </div> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Written by Tomas Zezula and Alyona Stashkova</p> |
| </div> |
| <div class="paragraph"> |
| <p>NetBeans IDE supports <a href="https://openjdk.org/projects/jdk8/features">JDK 8 features</a>, such as lambda expressions, repeatable annotations, compact profiles, etc. When these constructs are used in your code, the IDE recognizes them, correctly highlights errors, and lets you automatically fix syntax. Thus, NetBeans IDE helps you write code that is compatible with <a href="http://download.oracle.com/otndocs/jcp/java_se-8-edr-spec/index.html">Java SE 8 Release Contents Early Draft Review Specification</a>.</p> |
| </div> |
| <div class="paragraph"> |
| <p>In this tutorial, you will learn how to get started with JDK 8 in NetBeans IDE and how to use the IDE support for such Java SE 8 features as compact profiles, lambda expressions, and repeating annotations.</p> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../../_images/kb/docs/java/netbeans-stamp-80-74.png" alt="netbeans stamp 80 74"> |
| </div> |
| <div class="title">Figure 1. Content on this page applies to NetBeans IDE 7.4 and 8.0 Beta</div> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To complete this tutorial, you need the software and resources listed in the following table.</strong></p> |
| </div> |
| <table class="tableblock frame-all grid-all stretch"> |
| <colgroup> |
| <col style="width: 50%;"> |
| <col style="width: 50%;"> |
| </colgroup> |
| <thead> |
| <tr> |
| <th class="tableblock halign-left valign-top">Software or Resource</th> |
| <th class="tableblock halign-left valign-top">Version Required</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="../../../../../../front/main/download/" class="xref page">NetBeans IDE</a></p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">version 7.4 and 8.0</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 8</p></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_enabling_jdk_8_support_in_netbeans_ide"><a class="anchor" href="#_enabling_jdk_8_support_in_netbeans_ide"></a>Enabling JDK 8 Support in NetBeans IDE</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>After JDK 8 is downloaded and installed on your system, it needs to be registered in the IDE as follows:</p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>In the IDE, choose Tools > Java Platforms from the main menu.</p> |
| </li> |
| <li> |
| <p>Click Add Platform in the Java Platform Manager dialog.</p> |
| </li> |
| <li> |
| <p>In the Add Java Platform dialog, select Java Standard Edition and click Next.</p> |
| </li> |
| <li> |
| <p>Specify the directory that contains the JDK and click Next.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/jdk8.png"><img src="../../../../_images/kb/docs/java/jdk8_small.png" alt="jdk8 small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Verify that the default locations of the Platform Sources zip file and API documentation are valid. Click Finish to close the Add Java Platform dialog box. |
| JDK 8 is registered as a platform in the IDE.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/jdk8registered.png"><img src="../../../../_images/kb/docs/java/jdk8registered_small.png" alt="jdk8registered small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Ensure JDK 1.8 is chosen in the Platforms list and click Close.</p> |
| </li> |
| </ol> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_configuring_a_project_to_use_jdk_8"><a class="anchor" href="#_configuring_a_project_to_use_jdk_8"></a>Configuring a Project to use JDK 8</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>After you registered JDK 8 in the IDE, your project needs to be configured to use JDK 8 for compilation, running, and debugging.</p> |
| </div> |
| <div class="paragraph"> |
| <p>We will start by creating a new Java SE project with the Anagram game example which is shipped with NetBeans IDE.</p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>In the IDE, choose File > New Project.</p> |
| </li> |
| <li> |
| <p>In the New Project wizard, expand the Samples category and select Java.</p> |
| </li> |
| <li> |
| <p>Choose Anagram Game in the Projects list. Then click Next.</p> |
| </li> |
| <li> |
| <p>In the Name and Location panel, leave the default values for the Project Name and Project Location fields.</p> |
| </li> |
| <li> |
| <p>Click Finish. |
| The IDE creates and opens the Java SE project in the Projects window.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To configure your project to use JDK 8:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Right-click the AnagramGame project in the Projects window and select Properties from the context menu.</p> |
| </li> |
| <li> |
| <p>In the Project Properties dialog box, choose the Libraries category and set JDK 1.8 as the Java Platform.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/prj_jdk8.png"><img src="../../../../_images/kb/docs/java/prj_jdk8_small.png" alt="prj jdk8 small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Select the Sources category and set Source/Binary Format to JDK 8.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/prj_source_jdk8.png"><img src="../../../../_images/kb/docs/java/prj_source_jdk8_small.png" alt="prj source jdk8 small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Click OK to save the changes. |
| Your project is set to recognize new JDK 8 language features.</p> |
| </li> |
| </ol> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_using_compact_profiles_support"><a class="anchor" href="#_using_compact_profiles_support"></a>Using Compact Profiles Support</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Java SE 8 introduces <a href="https://openjdk.org/jeps/161">subset profiles of the Java SE platform specification</a> that can be used to deploy and run applications that do not require the entire platform.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Three profiles that have been defined so far are named <em>compact1</em>, <em>compact2</em>, and <em>compact3</em>. Each profile specifies a particular set of Java API packages and contains all of the APIs in profiles smaller than itself: <em>compact1</em> is a subset of <em>compact2</em>, which is a subset of <em>compact3</em>, which in its turn is a subset of the <em>full JRE</em>. The table below lists packages that are comprised in each profile.</p> |
| </div> |
| <table class="tableblock frame-all grid-all stretch"> |
| <colgroup> |
| <col style="width: 25%;"> |
| <col style="width: 25%;"> |
| <col style="width: 25%;"> |
| <col style="width: 25%;"> |
| </colgroup> |
| <thead> |
| <tr> |
| <th class="tableblock halign-left valign-top">Compact1</th> |
| <th class="tableblock halign-left valign-top">Compact2</th> |
| <th class="tableblock halign-left valign-top">Compact3</th> |
| <th class="tableblock halign-left valign-top">Full JRE</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">* java.lang |
| * java.io |
| * java.nio |
| * java.text |
| * java.math |
| * java.net |
| * javax.net |
| * java.util |
| * java.util.logging |
| * java.security |
| * javax.crypto |
| * javax.security</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><em>compact1</em> plus the following:</p> |
| <p class="tableblock">* java.sql |
| * javax.sql |
| * javax.xml |
| * org.w3c.dom |
| * org.xml.sax |
| * java.rmi |
| * javax.rmi |
| * javax.transaction</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><em>compact2</em> plus the following:</p> |
| <p class="tableblock">* java.lang.management |
| * javax.management |
| * javax.naming |
| * javax.sql.rowset |
| * javax.security.auth.kerberos |
| * org.ietf.jgss |
| * javax.script |
| * javax.xml.crypto |
| * java.util.prefs |
| * javax.security.sasl |
| * javax.security.acl |
| * java.lang.instrument |
| * javax.annotation.processing |
| * javax.lang.model |
| * javax.lang.model.element |
| * javax.lang.model.type |
| * javax.lang.model.util |
| * javax.tools</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock"><em>compact3</em> plus the following:</p> |
| <p class="tableblock">* corba |
| * awt |
| * swing</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <div class="paragraph"> |
| <p>The IDE allows you to switch between the profiles and the full JRE when needed.</p> |
| </div> |
| <div class="paragraph"> |
| <p><strong>To set a project profile for a Java SE Project:</strong></p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Right-cick a project and choose Properties from the context menu.</p> |
| </li> |
| <li> |
| <p>In the Project Properties dialog box, select the Sources category.</p> |
| </li> |
| <li> |
| <p>Use the Profile drop-down list to specify the JDK 8 profile that your application will support.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/prj_src_profile.png"><img src="../../../../_images/kb/docs/java/prj_src_profile_small.png" alt="prj src profile small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>Click OK.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="paragraph"> |
| <p>To see how the IDE checks whether classes used in your project belong to the specified profile, select Compact1 as a profile for the AnagramGame project and click OK. |
| The IDE displays errors to notify that the AnagramGame project is not compliant with the <em>compact1</em> profile.</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/profile.png"><img src="../../../../_images/kb/docs/java/profile_small.png" alt="profile small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>You can go back and set the AnagramGame project’s profile to Full JRE which is supported by the Anagrams application.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_using_lambda_expressions_support"><a class="anchor" href="#_using_lambda_expressions_support"></a>Using Lambda Expressions Support</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p><a href="https://openjdk.org/projects/lambda/">Lambda expressions</a> address the bulkiness of anonymous inner classes by expressing the machinery of anonymous inner classes more compactly.</p> |
| </div> |
| <div class="paragraph"> |
| <p>The general syntax of a lambda expression consists of a set of parameters, an arrow token, and a function body (either a single expression or a statement block):</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">(int a, int b) -> a * a + b * b;</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>NetBeans IDE detects pre-lambda expressions and displays the hints in the Editor proposing to turn such constructs into lambda expressions.</p> |
| </div> |
| <div class="paragraph"> |
| <p>For example, the AnagramGame project features a pre-lambda construct in the <code>Anagrams.java</code> file as shown in the screenshot below.</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/lambda.png"><img src="../../../../_images/kb/docs/java/lambda_small.png" alt="lambda small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>After you click the light bulb in the margin or press Alt-Enter, the IDE shows the Use Lambda hint with a set of options available:</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/lambda_clicked.png"><img src="../../../../_images/kb/docs/java/lambda_clicked_small.png" alt="lambda clicked small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>If the Use Lambda hint is selected, the IDE converts the anonymous inner class into a lambda expression.</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/lambda_converted.png"><img src="../../../../_images/kb/docs/java/lambda_converted_small.png" alt="lambda converted small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>If you choose the Run Inspect on option, the IDE displays the Inspect dialog box that allows to run a single Convert to Lambda inspection on the specified file.</p> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| For more information on initiating the Inspect operation in the IDE, see <a href="http://www.oracle.com/pls/topic/lookup?ctx=nb7400&id=NBDAG613">Using Hints in Source Code Analysis and Refactoring</a> in <em>Developing Applications with NetBeans IDE</em>. |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/inspect.png"><img src="../../../../_images/kb/docs/java/inspect_small.png" alt="inspect small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>After you press the Inspect button to launch the inspection, the IDE identifies all the pre-lambda constructs in the file and displays them in the Inspector window.</p> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/lambda_inspection.png"><img src="../../../../_images/kb/docs/java/lambda_inspection_small.png" alt="lambda inspection small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>If you choose the Run Inspect&Transform on option, the IDE displays the Inspect and Transform dialog box that allows to run a single Convert to Lambda inspection (or a selected configuration) on the specified code and refactor it if needed.</p> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| For more information on initiating the Inspect and Transform operation, see <a href="http://www.oracle.com/pls/topic/lookup?ctx=nb7400&id=NBDAG613">Using Hints in Source Code Analysis and Refactoring</a> in <em>Developing Applications with NetBeans IDE</em>. |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="openblock feature"> |
| <div class="content"> |
| <div class="imageblock xref-image left"> |
| <div class="content"> |
| <a class="image" href="../../../../_images/kb/docs/java/lambda_transform.png"><img src="../../../../_images/kb/docs/java/lambda_transform_small.png" alt="lambda transform small"></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_using_repeating_annotations_support"><a class="anchor" href="#_using_repeating_annotations_support"></a>Using Repeating Annotations Support</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Java SE 8 features include <a href="https://openjdk.org/jeps/120">repeating annotations</a> that enable you to apply annotations with the same type to a single program element, as shown in the following code example:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@ProjectServiceProvider(service=Foo.class,"org-nebeans-modules-j2seproject") |
| @ProjectServiceProvider(service=Foo.class,"org-nebeans-modules-j2eeproject") |
| public class MyService extends Foo {}</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>NetBeans IDE support for repeating annotations allows you to write code with the same annotations provided the repeatable and containing annotation types are declared:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>a repeatable annotation type must be marked with <code>@Repeatable ()</code> , otherwise you get an error at compilation</p> |
| </li> |
| <li> |
| <p>a containing annotation type must have a <code>value</code> element with an array type; the component type of the array type must be the repeatable annotation type</p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p><a href="../../../../../../front/main/community/mailing-lists/" class="xref page">Send Us Your Feedback</a></p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_see_also"><a class="anchor" href="#_see_also"></a>See Also</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>For more information about JDK 8, see:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="http://jdk8.java.net/">JDK 8 Project</a></p> |
| </li> |
| <li> |
| <p><a href="http://download.java.net/jdk8/docs/">Java Platform Standard Edition 8 Early Access Documentation</a></p> |
| </li> |
| <li> |
| <p><a href="http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html">+Java SE 8: Lambda Quick Start +</a></p> |
| </li> |
| <li> |
| <p><a href="http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html">The Java Tutorials: Lambda Expressions</a></p> |
| </li> |
| <li> |
| <p><a href="http://docs.oracle.com/javase/tutorial/java/annotations/repeating.html">The Java Tutorials: Repeating Annotations</a></p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>For more information about developing Java applications in the NetBeans IDE, see:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="http://www.oracle.com/pls/topic/lookup?ctx=nb8000&id=NBDAG366">Creating Java Projects</a> in <em>Developing Applications with NetBeans IDE</em></p> |
| </li> |
| <li> |
| <p><a href="../javase-intro/" class="xref page">Developing General Java Applications</a></p> |
| </li> |
| <li> |
| <p><a href="../../java-se/" class="xref page">General Java Development Learning Trail</a></p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <section class='tools'> |
| <ul class="menu align-center"> |
| <li><a title="Facebook" href="https://www.facebook.com/NetBeans"><i class="fa fa-md fa-facebook"></i></a></li> |
| <li><a title="Twitter" href="https://twitter.com/netbeans"><i class="fa fa-md fa-twitter"></i></a></li> |
| <li><a title="Github" href="https://github.com/apache/netbeans"><i class="fa fa-md fa-github"></i></a></li> |
| <li><a title="YouTube" href="https://www.youtube.com/user/netbeansvideos"><i class="fa fa-md fa-youtube"></i></a></li> |
| <li><a title="Atom Feed" href="https://netbeans.apache.org/blogs/atom"><i class="fa fa-mf fa-rss"></i></a></li> |
| <li><a title="Slack" href="https://tinyurl.com/netbeans-slack-signup/"><i class="fa fa-md fa-slack"></i></a></li> |
| <li><a title="Issues" href="https://github.com/apache/netbeans/issues"><i class="fa fa-mf fa-bug"></i></a></li> |
| </ul> |
| <ul class="menu align-center"> |
| <li><a href="https://github.com/apache/netbeans-antora-tutorials/edit/main/modules/ROOT/pages/kb/docs/java/javase-jdk8.adoc" title="See this page in github"><i class="fa fa-md fa-edit"></i> See this page in GitHub.</a></li> |
| </ul> |
| </section> |
| </article> |
| </div> |
| <div class='grid-container incubator-area' style='margin-top: 64px'> |
| <div class='grid-x grid-padding-x'> |
| <div class='large-auto cell text-center'> |
| <a href="https://www.apache.org/"> |
| <img style="height: 60px" title="Apache Software Foundation" src="../../../../../../_/images/asf_logo_wide.svg" /> |
| </a> |
| </div> |
| <div class='large-auto cell text-center'> |
| <a href="https://www.apache.org/events/current-event.html"> |
| <img style="width:234px; height: 60px;" title="Apache Software Foundation current event" src="https://www.apache.org/events/current-event-234x60.png"/> |
| </a> |
| </div> |
| </div> |
| </div> |
| <footer> |
| <div class="grid-container"> |
| <div class="grid-x grid-padding-x"> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/about">About</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/community/who">Who's Who</a></li> |
| <li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li><a href="https://www.apache.org/security/">Security</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/community">Community</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/community/mailing-lists">Mailing lists</a></li> |
| <li><a href="../../../../../../front/main/community/committer">Becoming a committer</a></li> |
| <li><a href="../../../../../../front/main/community/events">NetBeans Events</a></li> |
| <li><a href="https://www.apache.org/events/current-event.html">Apache Events</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/participate">Participate</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/participate/submit-pr">Submitting Pull Requests</a></li> |
| <li><a href="../../../../../../front/main/participate/report-issue">Reporting Issues</a></li> |
| <li><a href="../../../../../../front/main/participate/#documentation">Improving the documentation</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/help">Get Help</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/help/#documentation">Documentation</a></li> |
| <li><a href="../../../../../../wiki/main/wiki">Wiki</a></li> |
| <li><a href="../../../../../../front/main/help/#support">Community Support</a></li> |
| <li><a href="../../../../../../front/main/help/commercial-support">Commercial Support</a></li> |
| </ul> |
| </div> |
| <div class="large-auto cell"> |
| <h1><a href="../../../../../../front/main/download">Download</a></h1> |
| <ul> |
| <li><a href="../../../../../../front/main/download">Releases</a></li> |
| <li><a href="https://plugins.netbeans.apache.org/">Plugins</a></li> |
| <li><a href="../../../../../../front/main/download/#_daily_builds_and_building_from_source">Building from source</a></li> |
| <li><a href="../../../../../../front/main/download/#_older_releases">Previous releases</a></li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </footer> |
| <div class='footer-disclaimer'> |
| <div class="footer-disclaimer-content"> |
| <p>Copyright © 2017-2025 <a href="https://www.apache.org">The Apache Software Foundation</a>.</p> |
| <p>Licensed under the Apache <a href="https://www.apache.org/licenses/">license</a>, version 2.0</p> |
| <div style='max-width: 40em; margin: 0 auto'> |
| <p>Apache, Apache NetBeans, NetBeans, the Apache feather logo and the Apache NetBeans logo are trademarks of <a href="https://www.apache.org">The Apache Software Foundation</a>.</p> |
| <p>Oracle and Java are registered trademarks of Oracle and/or its affiliates.</p> |
| <p>The Apache NetBeans website conforms to the <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Apache Software Foundation Privacy Policy</a></p> |
| </div> |
| </div> |
| </div> |
| |
| |
| <script src="../../../../../../_/js/vendor/lunr.js"></script> |
| <script src="../../../../../../_/js/search-ui.js" id="search-ui-script" data-site-root-path="../../../../../.." data-snippet-length="100" data-stylesheet="../../../../../../_/css/search.css"></script> |
| <script async src="../../../../../../search-index.js"></script> |
| <script src="../../../../../../_/js/vendor/jquery.min.js"></script> |
| <script src="../../../../../../_/js/vendor/what-input.min.js"></script> |
| <script src="../../../../../../_/js/vendor/foundation.min.js"></script> |
| <script src="../../../../../../_/js/vendor/jquery.colorbox-min.js"></script> |
| <script src="../../../../../../_/js/netbeans.js"></script> |
| <script> |
| $(function(){ $(document).foundation(); }); |
| </script> |
| <script src="../../../../../../_/js/vendor/highlight.min.js"></script> |
| <script> |
| document.addEventListener('DOMContentLoaded', (event) => { |
| document.querySelectorAll('pre code').forEach((el) => { |
| hljs.highlightElement(el); |
| }); |
| }); |
| </script> |
| </body> |
| </html> |