| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <title>NetBeans Platform Runtime Container Tutorial for NetBeans Platform 6.5</title> |
| <link rel="stylesheet" type="text/css" href="https://netbeans.org/netbeans.css"> |
| <meta name="AUDIENCE" content="NBUSER"> |
| <meta name="TYPE" content="ARTICLE"> |
| <meta name="EXPIRES" content="N"> |
| <meta name="developer" content="tboudreau@netbeans.org"> |
| <meta name="indexed" content="y"> |
| <meta name="description" |
| content="A short guide to the NetBeans runtime container."> |
| <!-- Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. --> |
| <!-- Use is subject to license terms.--> |
| </head> |
| |
| <body> |
| |
| <h1>NetBeans Platform Runtime Container Tutorial</h1> |
| |
| <p>This tutorial covers the most fundamental concept in the NetBeans Platform—the runtime |
| container. The runtime container is the execution environment for the modules that define |
| a NetBeans Platform application. It consists of 5 modules provided by the NetBeans Platform. |
| In this tutorial, we will look at these 5 modules, and use them in a very simple modular |
| application. |
| |
| <p>Before going further, you can watch this video, which covers the same material as the |
| rest of this tutorial: |
| |
| <div id="videoPlayer"></div><p> |
| <script type="text/javascript"> |
| <!-- |
| var so = new SWFObject("http://www.netbeans.tv/images/playerWidget.swf" , "pv", "210", "160", "8", "#666666"); |
| so.addParam("quality", "high"); |
| so.addParam("allowScriptAccess", "sameDomain"); |
| so.addParam("allowFullScreen", "true"); |
| so.addVariable("autoPlay", "false"); |
| so.addVariable("urlFileIdList", "6734"); |
| so.addVariable("show_title", "true"); |
| so.addVariable("PLAY_CALLBACK","emphasize"); |
| so.addVariable("resizeLimitMax","true"); |
| so.addVariable("lang", "en"); |
| so.addVariable("flash_play","true"); |
| so.addVariable("author_name","NetBeans.tv"); |
| so.addVariable("configUrl","http://sun.ora.ma/config.sun.ora.ma.xml"); |
| so.write("videoPlayer"); |
| // --> |
| </script> |
| |
| <p><b>Contents</b> |
| |
| <p><img src="../images/articles/69/netbeans-stamp7-8-9.png" class="stamp" width="114" height="114" alt="Content on this page applies to NetBeans IDE 6.5, 6.7, 6.8" title="Content on this page applies to NetBeans IDE 6.5, 6.7, 6.8"/></p> |
| <ul class="toc"> |
| <li><a href="#intro">Introduction to the Runtime Container</a></li> |
| <li><a href="#setup">Setting up the Runtime Container</a></li> |
| <li><a href="#add">Loading a New Module into the Runtime Container</a></li> |
| </ul> |
| |
| <p><b>To follow this tutorial, you need the software and resources listed in the following table.</b></p> |
| |
| <table> |
| <tbody> |
| <tr> |
| <th class="tblheader" scope="col">Software or Resource</th> |
| <th class="tblheader" scope="col">Version Required</th> |
| </tr> |
| <tr> |
| <td class="tbltd1"><a href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></td> |
| <td class="tbltd1">version 6.7 or above</td> |
| </tr> |
| <tr> |
| <td class="tbltd1"><a href="http://java.sun.com/javase/downloads/index.jsp">Java Developer Kit (JDK)</a></td> |
| <td class="tbltd1">Version 6 or<br/>version 5</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <p><h2 class="tutorial"><a name="intro"></a>Introduction to the Runtime Container</h2> |
| |
| <p>The "NetBeans runtime container" is the collective name for these 5 |
| NetBeans Platform modules:</p> |
| |
| <p><img src="https://platform.netbeans.org/images/tutorials/runtime-container/runtime-container.jpg"/></p> |
| |
| <p>Brief overview of each of these 5 modules: |
| |
| <ul> |
| <li>Bootstrap—Enables the runtime container to understand what |
| a module is and how to load and compose them into one application. |
| <li>Startup—Provides the main method of your application, as well |
| as all the code needed for starting it up. |
| <li>Filesystem API—Gives your application a filesystem. |
| <li>Module System API—Lets you influence the lifecycle of |
| the modules in your application. |
| <li>Utilities API—Includes many utility classes, especially |
| the Lookup class, which is used for communication between modules. |
| </ul> |
| |
| <p><b>Note:</b> In NetBeans Platform 6.9, the Lookup classes are separated |
| into a separate module, named "Lookup API", which you will need to |
| set a dependency on, in addition to the modules listed above. |
| |
| <p><h2 class="tutorial"><a name="setup"></a>Setting up the Runtime Container</h2> |
| |
| <p>In this section, we will create an absolutely minimal NetBeans Platform application. |
| It will consist of only those modules that every NetBeans Platform application must |
| have—the 5 modules that make up the runtime container. Once we have create |
| an application that consists of nothing more than these 5 modules, we will run it. |
| There will be no specific output from this application. However, it will build and |
| run successfully because all the fundamental requirements of a NetBeans Platform |
| application will have been met. |
| |
| <ol> |
| <li><p>Go to File > New Project. In the New Project dialog, choose |
| NetBeans Modules > NetBeans Platform Application:</p> |
| <p><img src="https://platform.netbeans.org/images/tutorials/htmleditor/new-nb-app-wiz-65.png"/></p> |
| <p>Click Next.</p> |
| <li>Name your application 'Hello World'. Click Finish. |
| <li>Right-click the main project node in the Projects window, |
| choose Properties, and go to the Libraries tab. There you can |
| see all the modules that are part of this application. |
| <li>In addition to the runtime container, many other modules are |
| included. Exclude them now. Make sure that ONLY the 5 modules that make |
| up the runtime container are included. |
| </ol> |
| |
| <p>Run the application and notice that the application successfully |
| executes. |
| |
| <p><h2 class="tutorial"><a name="add"></a>Loading a New Module into the Runtime Container</h2> |
| |
| <p>In this section, we add one new module to the NetBeans runtime container. The new |
| module will do nothing special. The only reason for adding it will be so that you |
| can see that it will be an equal partner to the other modules in your application. |
| You will have six modules instead of 5: in addition to the 5 modules that you |
| already have, you will also have your custom module. |
| |
| <p>Next, we will influence the module's lifecycle. When it is loaded into the |
| runtime container, we will use one of the module's lifecycle methods to send |
| a 'Hello World' message to the Output window. |
| |
| <ol> |
| |
| <li>Right-click the application's Modules node and choose 'Add New...'. |
| Click Next. |
| |
| <li>Give your module a project name and a code name base. |
| Click Finish. You now have a new module. |
| |
| <li>Right-click the module, choose New > Other, and then choose |
| Module Development > Module Installer. |
| Click Next and then complete the wizard. You now have a new |
| class that extends 'ModuleInstaller', which is from the Module |
| System API. |
| |
| <li>Add a new 'System.out.println' message in the 'restored' method of |
| the Installer class. |
| |
| </ol> |
| |
| <p>Run the application again and notice the 'Hello World' message in the application's |
| output. One place where you can see the application's output is in the |
| IDE's Output window. |
| |
| <br> |
| <div class="feedback-box"><a href="https://netbeans.org/about/contact_form.html?to=3&subject=Feedback:%20Runtime%20Container%20API%20Tutorial%20NetBeans">Send Us Your Feedback</a></div> |
| <br style="clear:both;" /> |
| |
| <a name="next_steps"></a><h2>Next Steps</h2> |
| <p>For the next steps in the "NetBeans Platform Fundamentals" |
| series, see:</p> |
| <ul> |
| <li><a href="nbm-selection-1.html">NetBeans Selection Management Tutorial I—Using a TopComponent's Lookup</a> |
| <li><a href="nbm-10-top-apis.html">Top 10 NetBeans APIs</a> |
| <li><a href="http://dvbcentral.sourceforge.net/netbeans-runtime.html">NetBeans Runtime Container Manifesto</a> |
| </ul> |
| |
| </body> |
| </html> |