J2ME development environment Eclipseme
First section first Eclipse
Eclipse is a development source code, based on Java-extended development platform, is a integrated development platform (IDE) that is granted a license in the General Public License (CPL) version approved by OSI (Open Software Initirative Development Source Code) . As one of today's most popular Java development IDE, Java community uses Eclipse and IBM WebSphere, which is based on Eclipse technology, has exceeded half.
Eclipse itself is just a framework and a set of responding services, but because of a standard plug-in set, Eclipse is almost everything is plugin; at the same time, it allows developers in all fields to build a seamless integration with the Eclipse environment. .
The most prominent example of Eclipse application is IBM WebSphere Studio, which is the foundation of IBM Java development tools, which is essentially a variety of service plug-ins for Eclipse framework plus IBM development.
You can download to Eclipse decompression installation files, language packs, and many utility plugins in http://www.eclipse.org/downloads/index.org/downloads/index.php. The latest version is Eclipse SDK when writing this article.
3.1 m
5A. However, here the author remind everyone that Eclipse is not a version, better, new version often has some difficulties, and some plug-in providers may have not yet available. This article will use Eclipse-SDK-M
3.0.1 is demonstrated for everyone.
Since Eclipse is so important in Java development, can we use Eclipse to develop mobile apps? Yes, this answer is Eclipseme.
Eclipseme is a plugin as an Eclipse and is committed to helping developers develop J2ME applications. Eclipseme does not provide a wireless device simulation device for developers, while connecting the practical simulator of each mobile phone vendor to the Eclipse development environment, providing developers with a seamless uniform integrated development environment.
You can get a free download EclipseMe on http://www.eclipseme.org/, the latest version of this article is
0.7.5, which is also considered for stability, the author chooses Eclipseme.Feature_0.5.5_site.zip here to demonstrate.
In addition to Eclipse and Eclipseme, you also need Java runtime environment and some mobile simulators to complete the installation. The tool list of completing this article is listed below and the reference download address (pressing the order):
1. JDK
1.4.2 http://java.sun.com/j2se/1.4.2/download.html
2. Eclipse M
3.0.1 http://www.eclipse.org/downloads/index.php
2. Eclipse 3.0.x language package http://www.eclipse.org/downloads/index.php
3. Eclipseme
0.5.5 http://www.eclipseme.org/
4. Sun WTK V2.2 (Universal Simulator of SUN)
http:// java sun.com
Nokia Developer's Suite 2.2 (Nokia Developer Suite, including several typical simulators)
Http://www.forum.nokia.com/main/0,6566,034-2,00.html
The second section builds an Eclipse mobile development environment
1. Eclipse installation and Chinese
The first step of building Eclipse is to install JDK. When writing this article, the latest version of JDK is 5.0, but there are many problems with the development of the mobile phone with JDK5.0 Eclipse. So the current J2ME developer basically also uses JDK1.4.2, which is very simple, here is not described here.
Eclipse installation process is simpler, in fact, this is just a decompressed process. Eclipse SDK compression package you downloaded Eclipse-SDK-M
3.0.1 Copy Under your target directory, we use the D disk root directory as an example and then extract them to the current folder.
Don't rush to run your Eclipse environment, copy the Eclipse language package NLPACK-Eclipse-SDK-3.0 to the same path (D disk) to decompress, then run, Eclipse will first complete the first startup configuration, including the corresponding Chinese jobs. Specify your work space.
Welcome to the interface, it is the beautiful work interface of Eclipse!
2. Eclipseme plugin installation
Select "Help / Software Update / Finding and Update" in Eclipse, select "Search to install new features" in the pop-up dialog box, specify the EclipseMe compressed file Eclipseme.Feature_
0.5.5_site.zip.
After clicking OK, you can see that Eclipse has searched the corresponding plugin.
Select the Eclipseme check box, accept the protocol, ignore the functional part verification, and finally restart the console, the Eclipseme plugin has been installed smoothly.
In order to verify that EclipseMe is already installed, we open "Window / Preference" after the workbench is restarted, we can see a J2ME option, at this time, the first step in Eclipse mobile development, we have successfully !
Note: After installing Eclipseme, we have to make a little change for the original Eclipse configuration. Due to mobile development, we need to start the mobile emulator first, then the Eclipse default setting in the debug mode does not wait until the simulator startup will fail.
Modify this very simple, in the "Java / Debug" of the preferences, change the default settings to the following picture, the debug mode can be successfully launched.
3. Loading the vendor simulator
Eclipseme provides us with an integrated development environment, but just these are not enough, we also need one or more mobile simulators as the actual carrier running. At present, all major mobile phone manufacturers have a variety of models of mobile simulators, and Sun also provides a general simulator. Here we use Sun WTK and NOKIA Developer's Suite to demonstrate.
Sun WTK V2.2
WTK (Wireless Toolkit) is Sun for wireless developers for wireless developers. It has multiple mobile simulators, which we will bind WTK to Eclipse here, which will greatly improve the developer's work efficiency.
Of course, we have to install WTK installation. The installation process is also very simple, the system will automatically detect the path where the current JDK is located, reference the JDK.
Belck WTK to Eclipse.
Find path "Window / Preference / J2ME / Platform Component", right-click Wireless Toolkit on the right side of the dialog, we can add the current system existing emulator. After clicking the "Browse" button, we select the WTK installation directory.
EclipseMe automatically analyzes the current simulator type and is displayed.
After confirming, we found many configuration information about WTK on the Platform Component column. At this point, WTK has been integrated into Eclipseme. NOKIA Developer's
Suite 2.2
Suite 2.2
NOKIA has a variety of models of mobile simulators, in order to manage, it has introduced management software developer's suite for centralizing these simulators.
Developer's Suite itself is a toolkit that can run independently, which can also be binded by Eclipseme to enable developers to work with efficient work in an identical working environment.
Here, we use Nokia Developer's Suite 2.2, this version can be bound to Eclipse even when installing!
First, download the installation file from the Nokia Forum. If you have an old version of Developer's Suite in your computer, you need to uninstall the old version.
Nokia's development kit is the developer that is provided to the NOKIA Forum, so after accepting the installation agreement, you need to provide your username and installation serial number in the Nokia Forum.
The first installation does not have to worry, enter anything in the input, directly ignore the past, developer's suite will allow you to choose a proxy networking mode (if you don't have a proxy server to select No Proxy), then ask you Enter your username and password in the Nokia Forum. After the registration is successful, the serial number corresponding to the username will be sent to your mailbox, check it, you can continue! (Sometimes the behavior of the NOKIA sequence number will be very slow, no way, only, etc. J).
When we complete the certification, we will find a variety of installation methods, including independent installation or direct use of Eclipse.
If you select an integration with the Eclipse, then we must provide the current Eclipse installation directory.
If you have selected a stand-alone installation, after restarting the system, we select the installation directory of developer's suite in "Preference / J2ME / Platform Components" in "Preference / J2ME / Platform Components", Wireless Toolkits WTK, Nokia Developer Suit is also listed there!
Now, we can finally develop the first J2ME program with Eclipse! J
Section III uses Eclipse for wireless development
Create project
After completing the environmental construction, we can develop wireless applications in the way in Eclipse. Let's complete a classic Hello World program, here we choose to use Sun WTK 2.2 as a running simulator.
In the new options on the Eclipse Workbench, select J2ME MIDlet Suite to create a MIDP SUIT.
In the next step, we can see a variety of simulator devices to choose from, select "J2ME Wireless Toolkit 2.2 Midp 2.0 Platform", continue until the next step is completed.
At this point, in the package resource manager, the Hello World Suite item has been established, and we noticed that Eclipse automatically binds the J2ME Library runtime, and creates a JAD.
2. Create a MIDlet file
After completing the project creation, let me create a MIDlet class file, which is the entrance file of the entire kit. It is also a key class of Hello World. After selecting J2ME MIDlet, we can see that the system automatically inherits the MIDlet hyperclass. Make sure that three default method checkboxes are selected, enter the class name, complete the creation.
Open the Hello World, and we found that Eclipse has automatically generated program main body, inheritance method, and some comments.
Such a lot of repetition has been completed by Eclipse, so that we only need to fill in your own implementation process in the corresponding method.
First import interface class import javax.microedition.lcdui in the Hello World code. *;
Then, we only need to override the original constructor with the following code:
Public helloworld () {
Super ();
// TODO automatically generates constructor stub
Form form = new form ("Hello World");
Form.Append ("Welcome to J2ME World!");
Display.getdisplay (this) .SetCurrent (FORM);
}
So simple, the first J2ME is complete!
Section 4 performs MIDlet, packaging and confusion
1. Run the MIDlet file
On the Hello World project, right-click, select "Run ...",
In the pop-up dialog box, create a configuration in Wireless Toolkit Emulator, specify just Hello World as an entry file, apply setting, and finally run.
It can be seen that Eclipse automatically launches the WTK simulator and shows the welcome interface of Hello World!
2. Package and confusion
Packing, is to generate a JAR file for the kit to publish the project. Right-click on the target project, you can select Create Package in the J2ME option to generate a JAR package.
Confusion is to protect copyright, increasing the difficulty of re-compiling reading source code; at the same time, the volume of JAR package can be reduced. You can also find the option to create an confusing package in the J2ME option. But first, you need to first specify the installation location of the obfuscator in the current system.
We use open source free Proguard here.
3.0.1 as an aliasing. In "Preference / J2ME / Packaging / Obfuscation", by browsing the installation (decompression) path specified for ProGuard 3.0.1.
After the application is saved, you can successfully create confused packages.
note:
Many friends who used to use will find confusion even after the specified path, and often get a warning information similar to the following.
This error occurs is related to the JDK path. After we installed JDK (
1.4.2 Take an example), there are two JDK in the system environment variable, one is a JDK SDK, one is a runtime environment. Eclipse selection when decompressed installation is the latter, and starting procuard3.0.1 is the former.
Fix this problem is simple, in the "Preference / Java / Installed JRE" to change your JRE from pointing to runtime to point to SDK (ie JDK installation directory)