Explore the principles for developing a j2_application

Source: Internet
Author: User

This article will focus on developing the principles for using applications on small devices. In this chapter, we will review some precautions that need to be kept in mind when developing applications for small devices. Let's take a look at how to call the compiler when compiling a J2SE application. Finally, we will explore the packaging and deployment, and verify the role in advance during this process.

Guidelines for the Development of j2s applications

1. Develop a j2_application

1. Introduction

In this chapter, we will review some notes that need to be kept in mind when developing applications for small devices. Let's take a look at how to call the compiler when compiling a J2SE application. Finally, we will explore the packaging and deployment, and verify the role in advance during this process.

Precautions for designing and developing small Device Applications

Developing applications for small devices requires you to develop certain policies during the design phase. It is better to design applications for small devices strategically before writing code. Since you cannot take into account all the "gotchas", it is very painful to correct the code before developing the application.

2. The following are some design strategies that can be considered:

Keep the program simple. Remove unnecessary features and, if possible, build them into independent and secondary applications.

The smaller the program, the better. This should be obvious to all developers. The smaller the program, the less memory the device occupies and the less installation time it takes. You can consider packaging your Java application as a compressed Java file (jar.

Minimum memory usage during running. To minimize the memory used during running, use the scalar type instead of the object type. At the same time, it does not rely on the garbage collection program. You should leave the object reference blank when using the object to effectively manage the memory. Another way to reduce the memory required for running is to use a "inert" instance, which allocates objects only when necessary. Other methods to reduce excessive usage and peak memory usage on small devices include quickly releasing resources, reusing objects, and avoiding exceptions.

3. Considerations for designing and developing mobile device's j2_app

The rules for developing mobile device applications are the same as those for developing small devices as we mentioned earlier: first design and then code. Let's check some design suggestions that can be considered when developing mobile device applications:

Let the server do most of the work. Place Computation Tasks on the server so that the server can do this for you. Allows mobile devices to process the interface and perform the least computing work, while the server performs heavy work. Of course, the mobile devices for which you develop applications have an important impact on the difficulty and frequency of devices connecting to the server.
Select a programming language with caution. It is still in the growth stage and may not be the best choice. Depending on your needs, it may be better to select other object-oriented languages, such as C ++.

4. Performance Considerations

Encoding for performance. There are some encoding methods to obtain the optimum performance as the goal:

Use local variables. Accessing local variables is faster than accessing the member class.

Avoid String concatenation. String concatenation not only reduces performance, but also increases the memory usage of applications.

Use threads to avoid synchronization. Any operation with a running time of more than 1/10 seconds requires an independent thread. Avoid synchronization and improve performance.

5. Compilation considerations

Like other Java applications, you must compile the application before packaging and deploying the application. With J2SE, you still use the J2SE compiler and use appropriate options for calling.

Specifically, you need to use the-bootclasspath option to instruct the compiler to use the J2SE class instead of the J2SE class. Do not set the configuration class in the CLASSPATH of the compiler. This will cause a runtime error, because no matter what is in CLASSPATH, the compiler will first automatically search for the J2SE core class. In other words, the compiler will not be able to reference the classes or methods that are missing in the specific j2s configuration, resulting in a runtime error when trying to run the application.

6. Packaging and deployment considerations

Because it is designed for small devices with limited memory. Most of the commonly used Java advance verification has been removed from the virtual machine to form a smaller coverage area. As a result, it is necessary to verify the J2EE application before configuration. A check will be appended during the runtime to ensure that this class has not changed after advance verification.

The toolkit is used to strictly verify or check the correctness of classes in advance. CLDC provides a command line utility called advance verification, which can perform actual verification and insert some additional information into the class file. MIDP uses the wireless toolkit, which provides a GUI tool that can also be run from the command line.

Deployment depends on the platform you want to deploy. Applications must be packaged and configured in a format suitable for the j2_type device, as defined in a simple table.

Related Article

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.