blob: 93479885fa7305504c72d959b69d905c60a218b2 [file] [log] [blame]
<!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>
<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, or 7.1, refer to the <a href="../../71/javame/cdc-quickstart.html">NetBeans 6.9, 7.0, or 7.1 Java ME CDC Development Quick Start Guide</a>.</li>
<li>NetBeans IDE 7.2 does not support the Java ME SDK.</li>
</ul>
<h3>Contents</h3>
<img src="../../../images_www/articles/72/netbeans-stamp.gif" class="stamp" alt="Content on this page applies to NetBeans IDE 7.2.1" title="Content on this page applies to the NetBeans IDE 7.2.1" >
<ul>
<li><a href="#reqs">Requirements</a></li>
<li><a href="#platforms">Supported CDC Emulator Platforms</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.2.1 </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 or7</td>
</tr>
</tbody>
</table>
<h2>Supported CDC Emulator Platforms<a name="platforms"></a></h2>
<p>The IDE installer for the Windows operating system includes the <a href="http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk/index.html">Java ME SDK 3.2</a> which 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 (Sun 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="../../../kb/73/javame/cdcemulator-setup.html"> NetBeans CDC Platform Emulator Setup Guide</a>.</p>
</li>
</ul>
<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>
<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> &gt; <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, use the drop-down menus to choose <code>CDC Java(TM) Platform Micro Edition SDK 3.2</code> for the Java Platform and
<code>DefaultCdcPbpPhone1</code> as the Device. Leave the Profile settings as <tt>PBP-1.1</tt> like shown in the following picture.
<p class="align-center">
<a href="../../../images_www/articles/72/javame/cdc-quickstart/select-platform.png" rel="lytebox" title="New CDC Project Wizard Select Platform Page">
<img src="../../../images_www/articles/72/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 the new application and opens the main class form.</li>
<li>In the Source view, find <code>g.drawString(&quot;Hello, World!&quot;, 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/72/javame/cdc-quickstart/hellojava.png" rel="lytebox" title="The Source Code editor with the string Hello Java World!">
<img src="../../../images_www/articles/72/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 &gt; Build Project from the main toolbar.</li>
<li>Choose Run &gt; Run Project from the main toolbar to run your project.<br> The project launches in the emulator and and displays the
modified &quot;Hello World!&quot; message.
<p class="align-center"><a href="../../../images_www/articles/72/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/72/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="../../../kb/docs/java/junit-intro.html">using the JUnit framework</a>.</p>
<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. The Sony
Ericsson platform also supports the Personal Profile. </p>
<ol>
<li>Choose <tt>File</tt> &gt; <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/72/javame/cdc-quickstart/nokias80app.png" rel="lytebox" title="New Project Wizard Name and Location showing S80cdcApplication project">
<img src="../../../images_www/articles/72/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/72/javame/cdc-quickstart/nokias80sdk.png" rel="lytebox" title="New Project Wizard Select Platform showing Nokia S80 CDC SDK">
<img src="../../../images_www/articles/72/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/72/javame/cdc-quickstart/nokia-screen.png" rel="lytebox" title="The main class form open in the GUI Builder">
<img src="../../../images_www/articles/72/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> &gt; <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/72/javame/cdc-quickstart/nokia-finished.png" rel="lytebox"
title="Sample Form in the GUI Builder">
<img src="../../../images_www/articles/72/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/72/javame/cdc-quickstart/app-emulator.png" rel="lytebox"
title="Sample application in the device emulator">
<img src="../../../images_www/articles/72/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="../../../kb/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;" >
<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="../../../kb/73/javame/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>
</body>
</html>