<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<!-- | |
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. | |
--> | |
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="../../../netbeans.css"> | |
<title>NetBeans Java ME CDC Development Quick Start Guide</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta http-equiv="Content-Style-Type" content="text/css"> | |
<meta name="SourceCastVersion" content="2.6.2.4.10"> | |
<meta name="keywords" content="NetBeans, IDE, Platform, open source, developer, Java ME, CDC"> | |
<meta name="Alyona Stashkova" content="Alyona.Stashkova@oracle.com"> | |
</head> | |
<!-- Begin Content Area --> | |
<body> | |
<a name="top"></a> | |
<h1>NetBeans Java ME CDC Development Quick Start Guide</h1> | |
<h2>Introduction</h2> | |
<p>Connected Device Configuration (CDC) applications are designed to run on mobile and embedded devices with at least 2MB of memory. This configuration supports | |
a more feature-rich JVM than MIDP-based mobile phones, which typically have much less memory and use the Connected Limited Device Configuration (CLDC). This tutorial shows you how to use NetBeans IDE to create a Java Platform, Micro Edition (Java ME platform) CDC application. We show you how to create a Java ME CDC project that displays a simple form in a device emulator for the three available CDC profiles. This document is designed to get you creating applications as quickly as possible. </p> | |
<p class="notes"><b>Note:</b></p> | |
<ul> | |
<li>If you are using NetBeans IDE 6.9, 7.0, 7.1.1, or 7.1.2, refer to the <a href="../../71/javame/cdc-quickstart.html">NetBeans 6.9, 7.0, 7.1.1, or 7.1.2 Java ME CDC Development Quick Start Guide</a>.</li> | |
<li>If you are using NetBeans IDE 7.2.1, refer to the <a href="../../72/javame/cdc-quickstart.html">NetBeans 7.2.1 Java ME CDC Development Quick Start Guide</a>.</li> | |
<li>Versions 7.1 and 7.2 of the NetBeans IDE do not support Java ME SDK.</li> | |
</ul> | |
<h3>Contents</h3> | |
<img src="../../../images_www/articles/73/netbeans-stamp.png" class="stamp" alt="Content on this page applies to NetBeans IDE 7.3" title="Content on this page applies to the NetBeans IDE 7.3" > | |
<ul> | |
<li><a href="#reqs">Requirements</a></li> | |
<li><a href="#platforms">Supported CDC Emulator Platforms</a></li> | |
<li><a href="#sdkinstall">Installing Oracle Java ME SDK</a></li> | |
<li><a href="#cdcinstall">Installing Oracle Java ME CDC Platform</a></li> | |
<li><a href="#plugin">Activating Java ME</a></li> | |
<li><a href="#pbp">Creating a CDC Application with Personal Basis Profile</a></li> | |
<li><a href="#personal">Creating a CDC Application with Personal Profile</a></li> | |
<li><a href="#next">See Also</a></li> | |
</ul> | |
<h2>Requirements<a name="reqs"></a></h2> | |
<p><b>To complete this tutorial, you need the following software and resources:</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 with Java ME</a></td> | |
<td class="tbltd1"> 7.3 </td> | |
</tr> | |
<tr> | |
<td class="tbltd1"><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit</a> (JDK)</td> | |
<td class="tbltd1"> 6 or 7</td> | |
</tr> | |
</tbody> | |
</table> | |
<h2>Supported CDC Emulator Platforms<a name="platforms"></a></h2> | |
<p>The NetBeans IDE supports the <a href="http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk/index.html">Java ME SDK 3.2</a> for the Windows operating system. The Java ME SDK 3.2 allows you to develop CDC applications. | |
Note that different CDC emulator platforms support different development profiles. The main development profiles and the emulators that support them are:</p> | |
<ul> | |
<li>Personal Basis Profile (Java ME SDK) supports an application development framework for mobile and embedded devices | |
(<a href="http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk/index.html">more info</a>)</li> | |
<li>Personal Profile (Nokia) is the most popular profile for smartphone development (<a href="http://java.sun.com/products/personalprofile/">more info</a>) | |
<p class="notes"><b>Note:</b> Instructions for adding the Nokia Series 80 Platform SDK for Symbian OS, Java and Personal Profile emulator platform are listed in the <a href="cdcemulator-setup.html"> NetBeans CDC Platform Emulator Setup Guide</a>.</p> | |
</li> | |
</ul> | |
<a href="#top">top</a> | |
<h2><a name="sdkinstall"></a>Installing Oracle Java ME SDK (on Windows)</h2> | |
<ol> | |
<li>Go to the <a href="http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk/index.html">Java ME SDK Download</a> page.</li> | |
<li> Click the Accept License Agreement option.</li> | |
<li>Download the oracle_java_me_sdk-3_2.exe installer file and save it to any location on your computer.</li> | |
<li>Double-click the installer file to run the installer, and follow the instructions.<br> | |
When the installation is complete, the Java (TM) ME Platform SDK 3.2 Device Manager icon (<img src="../../../images_www/articles/73/javame/cdc-quickstart/icon.png" alt="Java (TM) ME Platform SDK 3.2 Device Manager icon" border=1>) appears in the Windows system tray. </li> | |
</ol> | |
<a href="#top">top</a> | |
<h2><a name="cdcinstall"></a>Installing Oracle Java ME CDC Platform</h2> | |
<ol> | |
<li>Choose Tools > Java Platforms.<br> | |
The Java Platform Manager dialog box displays. | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/jpmanager.png" rel="lytebox" | |
title="Java Platform Manager"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/jpmanager-small.png" | |
alt="Java Platform Manager" border=1></a></p></li> | |
<li>Click Add Platform.</li> | |
<li>In the Select Platform Type step of the Add Java Platform wizard, select Java ME CDC Platform Emulator and click Next.<br> | |
The IDE displays the Choose Platform Folder step.</li> | |
<li>Select the directory you installed the Java ME SDK Platform to (for example, <tt>C:\Java_ME_Platform_SDK_3.2</tt>) and click Next.</li> | |
<li>In the Platform Name panel of the Add Java Platform wizard, ensure the platform you selected in the previous step is chosen and click Finish.<br> | |
The Oracle Java ME CDC Platform is now registered in the Netbeans IDE. | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/cdcregistered.png" rel="lytebox" | |
title="J2ME Platform registered"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/cdcregistered-small.png" | |
alt="J2ME Platform registered" border=1></a></p></li> | |
<li>In the Java Platform Manager dialog box, click Close.</li> | |
</ol> | |
<a href="#top">top</a> | |
<h2><a name="plugin"></a>Activating Java ME</h2> | |
<ol> | |
<li> Choose Tools > Plugins from the main IDE's toolbar.</li> | |
<li> In the Plugins dialog box, click the Installed tab and select Java ME in the list of available features. | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/plugins.png" rel="lytebox" title="Plugins dialog box"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/plugins-small.png" alt="Plugins dialog box" border=1></a></p></li> | |
<li> Click Activate.<br> | |
At the Welcome panel of the Installer dialog box, click Activate. | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/installer.png" rel="lytebox" title="Installer dialog box"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/installer-small.png" alt="Installer dialog box" border=1></a></p></li> | |
<li> When the activation is successfully completed, click Finish.</li> | |
<li> Click Close to close the Plugins dialog box.</li></ol> | |
<p>Now your NetBeans IDE is set up for mobile development.</p> | |
<p>In the following sections we create a CDC project using each available profile and also use the IDE's GUI builder in the Personal | |
and AGUI profile applications to enhance the User Interface. </p> | |
<a href="#top">top</a> | |
<h2>Creating a New CDC Application - Personal Basis Profile<a name="pbp"></a></h2> | |
<p>Here we create a CDC Application for the Personal Basis Profile (PBP) 1.1 Profile using the Java ME SDK 3.2. </p> | |
<ol> | |
<li>Choose <tt>File</tt> > <tt>New Project (Ctrl+Shift+N)</tt> from the main window.</li> | |
<li>From Categories, select <tt>Java ME</tt>. From Projects, select <tt>CDC Application</tt>. | |
Click Next.</li> | |
<li>In the Name and Location page, name the project <code>newcdc</code> and leave the <tt>Create Main Class</tt> checkbox checked. Click Next.</li> | |
<li>In the Select Platform page, leave the default settings - <code>CDC Java(TM) Platform Micro Edition SDK 3.2</code> (Java Platform), | |
<code>DefaultCdcPbpPhone1</code> (Device), and <tt>PBP-1.1</tt> (Profile) - like shown in the following picture. | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/select-platform.png" rel="lytebox" title="New CDC Project Wizard Select Platform Page"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/select-platform-small.png" alt="New CDC Project Wizard Select Platform Page" border=1></a></p></li> | |
<li>Click Finish. The IDE creates a new application and opens the main class form.</li> | |
<li>In the Source view, find <code>g.drawString("Hello, World!", 80, 50);</code> and add the word <tt>Java</tt> so that it reads <code>Hello, Java World!</code> | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/hellojava.png" rel="lytebox" title="The Source Code editor with the string Hello Java World!"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/hellojava-small.png" alt="The Source Code editor with the string Hello Java World!" border=1></a></p> | |
</li> | |
<li>To build the project, choose Run > Build Project from the main toolbar.</li> | |
<li>Choose Run > Run Project from the main toolbar to run your project.<br> The project launches in the emulator and and displays the | |
modified "Hello World!" message. | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/hellojava-emulator.png" rel="lytebox" title="The Default Color Phone Device Emulator with the message Hello Java World!"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/hellojava-emulator-small.png" alt="The Default Color Phone Device Emulator with the message Hello Java World!" border=1></a></p> | |
</li> | |
</ol> | |
<p>You can also debug the project and create tests for CDC projects <a href="../../docs/java/junit-intro.html">using the JUnit framework</a>.</p> | |
<a href="#top">top</a> | |
<a name="personal"></a> | |
<h2>Creating a New CDC Application - Personal Profile</h2> | |
<p>Here we create an <em>applet</em> for the Personal Profile using the Nokia | |
Series 80 Platform SDK for Symbian OS, for Java, Personal Profile. </p> | |
<ol> | |
<li>Choose <tt>File</tt> > <tt>New Project (Ctrl+Shift+N)</tt>. Under Categories, select | |
<tt>Java ME</tt>. Under Projects, select the <tt>CDC Application</tt> template. Click Next.</li> | |
<li>Name the project <tt>S80cdcApplication</tt> and specify a location for | |
the project on your computer. Leave the <tt>Create Main Class</tt> check box selected. | |
Click Next. | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/nokias80app.png" rel="lytebox" title="New Project Wizard Name and Location showing S80cdcApplication project"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/nokias80app-small.png" alt="New Project Wizard Name and Location showing S80cdcApplication project" border=1></a></p></li> | |
<li> In the Select Platform Page, choose the <tt>Nokia S80 Platform</tt>. | |
<p class="align-center"><a href="../../../images_www/articles/73/javame/cdc-quickstart/nokias80sdk.png" rel="lytebox" title="New Project Wizard Select Platform showing Nokia S80 CDC SDK"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/nokias80sdk-small.png" alt="New Project Wizard Select Platform showing Nokia S80 CDC SDK" border=1></a></p></li> | |
<li>Click Finish. The IDE creates a new application and opens the main class | |
form in the GUI Builder, as shown in the following figure. Click on Source | |
to see the source code for the applet. | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/nokia-screen.png" rel="lytebox" title="The main class form open in the GUI Builder"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/nokia-screen-small.png" alt="The main class form open in the GUI Builder" border=1></a></p> | |
<p class="notes"><b>Note:</b> The generated code is based on the profile. Here the main class is derived from <code>java.awt.Frame</code>. </p> | |
</li> | |
</ol> | |
<h4>Creating the Application Interface Using the GUI Builder</h4> | |
<p>You can use the GUI Builder in the same way you use it for regular J2SE development. | |
In the GUI Builder, right-click the <tt>Main.java</tt> form | |
and choose <tt>Set Layout</tt> > <tt>Free Design</tt>. Then drag and drop components from | |
the Palette window into the Design Area of the GUI Builder. </p> | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/nokia-finished.png" rel="lytebox" | |
title="Sample Form in the GUI Builder"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/nokia-finished-small.png" | |
alt="Sample Form in the GUI Builder" border=1></a></p> | |
<p class="notes"><b>Note:</b> Make sure you | |
only use AWT components in your form. Since all the Nokia Series 80 | |
devices support the Personal Profile, only AWT widgets are available.</p> | |
<p>For more information on using the IDE's GUI Builder, see the <a href="../../trails/matisse.html">Java GUI Applications Learning Trail</a>.</p> | |
<p> When you are done, right-click the project in the Projects window and | |
choose Run from the popup menu. Your application should be displayed in the device emulator.</p> | |
<p class="align-center"> | |
<a href="../../../images_www/articles/73/javame/cdc-quickstart/app-emulator.png" rel="lytebox" | |
title="Sample application in the device emulator"> | |
<img src="../../../images_www/articles/73/javame/cdc-quickstart/app-emulator-small.png" | |
alt="Sample application in the device emulator" border=1></a></p> | |
<p>You can now run the device in the emulator.</p> | |
<p>You can also debug the project, and create and debug tests <a href="../../docs/java/junit-intro.html">using the JUnit framework</a>.</p> | |
<div class="feedback-box"><a href="/about/contact_form.html?to=6&subject=NetBeans%20CDC%20Development%20Quick%20Start%20Guide">Send Feedback on This Tutorial</a></div><br style="clear:both;" > | |
<a href="#top">top</a> | |
<h2>See Also<a name="next"></a></h2> | |
<blockquote> | |
<p>More information about developing mobile applications using the IDE can be found at the following locations:</p> | |
<ul> | |
<li><a href="http://wiki.netbeans.org/JavaMESDKSupport">FAQ on Java ME SDK Support in NetBeans IDE</a></li> | |
<li><a href="cdcemulator-setup.html">NetBeans CDC Emulator Platform Setup Guide</a></li> | |
<li><a href="../../../kb/trails/mobility.html">NetBeans Java ME Applications Learning Trail</a></li> | |
</ul> | |
</blockquote> | |
<a href="#top">top</a> | |
</body> | |
</html> |