The eclipseme of constructing J2ME development environment

Source: Internet
Author: User
Tags bind constructor copy interface new features pack zip

The eclipseme of constructing J2ME development environment







First section Eclipse



Eclipse is a development source code, a java-based extensible development platform that is licensed under the general Public License (CPL) version of the OSI (Open Software Initiative Development Source Plan) (IDE). As one of the most popular Java development Ides today, the Java community has more than half the developer of IBM WebSphere using Eclipse and Eclipse technology.



Eclipse itself is a framework and a set of responsive services, but with a standard set of plug-ins, almost everything in Eclipse is a plug-in, and it allows developers in all areas to build tools that seamlessly integrate with the eclipse environment.



The most prominent example of an Eclipse application is IBM Websphere Studio, which is the foundation of the IBM Java Development tool, essentially the Eclipse framework plus the many service Plug-ins developed by IBM.



You can download the extract installation files for Eclipse in http://www.eclipse.org/downloads/index.php, language packs, and many utility plug-ins. The latest version of this writing is the Eclipse SDK 3.1 m5a. However, here I would remind you that eclipse is not as new as it is, and that the new version often has some difficult bugs to explain, and some plug-in providers may not have had time to provide a matching version. This article will use eclipse-sdk-m3.0.1 for everyone to demonstrate.







Since eclipse is so important in Java development, can we use eclipse to develop mobile apps? Yes, the answer is Eclipseme.



Eclipseme is a plug-in for Eclipse and is dedicated to helping developers develop J2ME applications. Eclipseme does not provide a wireless device simulator for developers, but connects the utility simulators of each handset manufacturer tightly to the Eclipse development environment, providing a seamless and unified integrated development environment for developers.



You can get free download on the http://www.eclipseme.org/Eclipseme, the latest version of this article is 0.7.5, also for the sake of stability, the author here to choose Eclipseme.feature_0.5.5_ Site.zip to show you.







In addition to eclipse and Eclipseme, you will need a Java runtime environment and some phone simulators to complete the installation. The following is a list of tools to complete this article and a reference download address (in the order of installation):



1. JDK 1.4.2 http://java.sun.com/j2se/1.4.2/download.html



2. Eclipse M3.0.1 http://www.eclipse.org/downloads/index.php



2. Eclipse 3.0.X Language Pack http://www.eclipse.org/downloads/index.php



3. Eclipseme 0.5.5 http://www.eclipseme.org/



4. Sun WTK V2.2 (Sun's universal simulator)



Http://java sun.com



Nokia Developer ' s Suite 2.2 (Nokia Developer suite, including several more typical models of the simulator)



Http://www.forum.nokia.com/main/0,6566,034-2,00.html















The second section builds the Eclipse Mobile development environment



1. Eclipse Installation and Localization



The first step in building eclipse is to install the JDK, and the latest version of the JDK is 5.0 when writing, but there are many problems with JDK5.0 + Eclipse to develop mobile programs. So the current J2ME developers are basically still using the JDK1.4.2, installation is very simple, here is not to repeat.



Eclipse's installation process is simpler, in fact, it's just a process of decompressing. Copy your download of the Eclipse SDK Compression pack eclipse-sdk-m3.0.1 to your target directory, where we take the D-packing directory as an example and extract it into the current folder.



Don't rush to run your eclipse environment, copy the Eclipse Language pack nlpack-eclipse-sdk-3.0 to the same path (d disk), and then run, and Eclipse will first complete the first boot configuration, including the corresponding Chinese work. Specify your working space.













After the welcome interface, it is Eclipse's beautiful working interface!















2. Eclipseme Plug-in Installation



Select Help/Software update/Find and update in Eclipse, select "Search for new features to install" In the pop-up dialog box, and in the pop-up box of the new archived site, specify the eclipseme compressed file eclipseme.feature_0.5.5_ Site.zip.











Click OK to see that eclipse has already searched for the appropriate plugin.









Check the Eclipseme checkbox, accept the protocol, ignore the functional component verification, and finally reboot the console, the Eclipseme plugin has been successfully installed.







































To verify that Eclipseme is actually installed, we can see a j2me option when we open windows/preferences after the work table has been restarted, and then we have successfully taken the first step in Eclipse mobile development.







Note: After installing the eclipseme, we will make a little change to the original eclipse configuration. Because we need to start the phone simulator first in mobile development, the Eclipse defaults in debug mode are not equal to the emulator startup failure.



Modifying this is very simple, in the preferences of "Java/debug", the default settings are changed to the following figure, Debug mode can be successfully started.



















3. Load Vendor Simulator



Eclipseme provides us with an integrated development environment, but only these are not enough, we also need one or more mobile phone simulators as the actual carrier of the program operation. At present, the major mobile phone manufacturers have a variety of models of mobile phone simulator, Sun also provides a general-purpose simulator. Here we use the Sun wtk and Nokia Developer ' s Suite two to show you.







Sun WTK v2.2



WTK (Wireless toolkit) is a wireless development utility package provided by Sun for wireless developers. It has multiple phone simulators, where we bind WTK to eclipse, which will greatly improve the productivity of developers.



Of course, first of all, we have to install WTK. The installation process is also simple, and the system automatically detects the path to the current JDK, referencing the JDK.



I'll bind WTK to eclipse below.



Locate the Path window/preference/J2me/platform Component, right-click the Wireless toolkit on the right side of the dialog box, and we can add the current system already has an emulator. After you click the Browse button, we select the WTK installation directory.









Eclipseme automatically analyzes the current simulator type and displays it.









After confirmation, we found that platform component A lot of configuration information about WTK, at which point WTK has been integrated into the eclipseme.













Nokia Developer ' s Suite 2.2



Nokia has a number of models for mobile phone simulators, for unified management, it has launched a centralized management of these simulators management software developer ' s Suite.



Developer's suite itself is a stand-alone toolkit that can also be eclipseme bound to enable developers to work efficiently in a similar working environment.



Here, we use the Nokia Developer ' s Suite 2.2, which can be bound to eclipse even when it's installed!







First, download the installation files from the Nokia forum, and if you have an older version of Developer's Suite in your computer, you need to uninstall the old version first.



Nokia's development packages are available to developers of the Nokia Forum, so after accepting the installation agreement, you will need to provide your username and installation serial number at the Nokia forum.









The first installation has no serial number also do not worry, input a column of what all do not have to fill in the past, Developer's suite will allow you to choose a proxy networking mode (if you do not use proxy server to access the Internet on the choice of no proxy), Then ask you to enter your username and password in the Nokia forum to register. After the successful registration, the serial number of the user name will be sent to your mailbox, check it, you can continue! (sometimes Nokia sends serial number behavior will be very slow, no way, only wait for j).























When we have completed our certification, we find that developer's Suite 2.2 offers a variety of installation options, including stand-alone installations or direct integration with eclipse.















If you chose to integrate with Eclipse, we will provide the installation directory for the current eclipse.













If you choose to install independently, after restarting the system, we will, in the same way as adding sun WTK, select the Developer ' suite of installation directory in ' Preferences/j2me/platform components ', and then we can see that Wireless Toolkits in addition to Wtk,nokia Developer suit is also listed in it!













Now, we can finally use eclipse to develop the first J2ME program! J











Section III using Eclipse for wireless development



1. Create the project



Once the environment has been built, we can develop the wireless application in eclipse in a way that we are familiar with. Let's finish a classic Hello World program, where we choose to use Sun WTK 2.2 as a running simulator.



In the new option on the Eclipse Workbench, select the J2ME Midlet Suite to create a MIDP Suit first.









In the next step, we can see a variety of simulator devices to choose from, and after selecting "J2me Wireless Toolkit 2.2 MIDP 2.0 Platform", proceed to the next step until completed.









At this point, in Package Explorer, the Hello World Suite Project has been built, and we notice that eclipse automatically binds us to the J2ME Library runtime and creates configuration files such as Jad.











2. Create MIDlet files



Once you have finished creating the project, let me create a MIDlet class file, which is the entry file for the entire suite. is also the key class of Hello world.









After selecting J2me MIDlet, we can see that the system automatically inherits the MIDlet superclass, make sure that the three default methods check boxes are selected, enter the class name, and complete the creation.







Opening the Hello world just created, we found that eclipse has automatically helped us generate program principals, inheritance methods, and some annotations.







So much repetitive work has been done by eclipse that we just need to fill in our own implementation process in the appropriate way.



First of all, in the Hello World Code Import interface class import javax.microedition.lcdui.*;



Then we just need to overwrite the original constructor with the following code:



Public HelloWorld () {



Super ();



TODO automatically generate constructor stubs



Form form = new Form ("Hello World");



Form.append ("Welcome to J2ME world!");



Display.getdisplay (This). Setcurrent (form);



}



So simple a few steps, the first J2ME is finished!











Section Fourth performing MIDlet, packaging and obfuscation



1. Running MIDlet files



Right-click on the Hello World project and choose "Run ..."











In the pop-up dialog box, create a new configuration in wireless Toolkit emulator, specify just hello World as the entry file, apply settings, and finally run.











As you can see, Eclipse automatically launches the WTK simulator, which shows the welcome interface of Hello World!













2. Packaging and obfuscation



Packaging is the creation of a jar file for the suite that is used to publish the project. Right-click the target item, and you can select Create Package in the J2ME option to generate the jar package.













Confusing, is to protect copyright, increase others to decompile reading source code difficulty, at the same time can reduce the volume of jar package. The option to create a confusing package can also be found in the J2ME option. First, however, you need to first specify where the obfuscation is installed in the current system.



We use the open source free Proguard3.0.1 as the obfuscation device here. In Preferences/j2me/packaging/obfuscation, browse to the installation (decompression) path of the specified Proguard3.0.1.













After you apply the Save settings, you can create a confusing package successfully.







Attention:



Many of your first-time friends will find that even after you specify a path, you still can't create confusion and often get a warning similar to the following.













This error occurs because of the JDK path. After we have installed the JDK (take 1.4.2 as an example), there are two types of JDK in the system environment variable, one is the JDK SDK, the other is the Run-time environment (runtime). Eclipse chooses the latter when extracting the installation, and the first need to start Proguard3.0.1 is the former.



Fixing this problem is simple, in the preferences/Java/installed JRE, change your JRE from point to run to point to SDK (that is, the installation directory of the JDK)





















At this point the JRE will have a full JDK library file, run the Create confusion again, and we'll find that Helloworld.jar,helloworld_base.jar is included in the Hello World subdirectory deployed, Helloworld_base_ Obf.jar. They are confused, confused, and mixed before the different versions of Jar packs.
























Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.