If you used to search for information about Java 2 Micro Edition on a http://www.javasoft.com website, you would be confused by a bunch of technical terms. What are KVM, cldc, CDC, MIDP, and other terms such as personal Java, embedded Java, and jes. Although it is called a tiny version of Java, its world is really not small, so we are full of questions about "seeing mountains is not mountains, seeing water is not water. Indeed, when I first came into contact with Java 2 Micro Edition, I felt that the more I looked at it, the less I could find myself confused. Therefore, in this chapter, I discard the technical details and hope to take you into consideration the world of Java 2 Micro Edition from a macro perspective. I hope that after reading this article, you will be able to experience the feeling of "seeing mountains and mountains, seeing water. First, we must first understand the positioning of Java 2 Micro Edition in the entire Java technology.
Development of Java programs of different versions
As mentioned above, the integrity of the core category Library supported by different Java versions and the supported Java basic types differ from each other, that is, whether you are developing a Java program used by the enterprise, a Java program executed on an embedded device, an applet executed on a browser, or an application executed on a PC. You must first install j2se on your computer, and then install the core category library and additional extended category library of various versions, in this way, Java programs for different purposes can be developed successfully. Java compilers (javac.exe) provided by j2se can help us compile Java programs on different platforms, while Java virtual machines (java.exe) provided by j2se can) in this way, we can test whether the execution results of these programs are correct on the PC. In addition, the Java compiler does not help you check whether your program meets the core category library and Java basic types supported on various platforms. For example, although we have mentioned earlier that the smart card version does not support Java basic types other than Boolean and byte, and the platform only supports Java. lang. * core category, but when we write a program on the smart card platform, even if the program code uses a Java basic type other than Boolean OR byte, or uses Java. lang. * For other core categories, the compiler can still help you compile the category files as usual. At this time, you must start to get confused-if these programs are put on the smart card header for execution, what if there is a problem? Won't it cause an error when executing the virtual machine on the smart card? Sun Microsystems may include a checker or prereviewer preverifier in different development kits for this potential problem ), these two tools can help you check and pre-review programs before they are placed on the target platform. The checker will help you find out the parts that do not match the Target Platform specification in the category file and remind you that these parts may not be executed on the target platform. Therefore, with the assistance of the scanner, you can determine that your program can comply with the requirements of the target platform and be executed smoothly. The Java card development kit contains a checker.
The Development kits of some platforms are attached with the pre-review tool. In addition to the work done by the pre-audit tool, there is also an additional task to reduce the burden on virtual machines on the target platform, it is necessary to explain the additional work of the pre-reviewer. In traditional Java programs, for security considerations, any category that enters the execution environment (whether from the local machine or remote machine) must be verified by the byte code reviewer (byte code verifier, in order to prevent the program from being maliciously modified during transmission, so that the Java program has a negative impact on the system during execution. After review, this category can start to be executed by the J virtual machine. If the review is executed on a general PC, the speed is acceptable, however, once placed on a machine such as palm or mobile phone with slow CPU and less memory, it seems very difficult. To save valuable CPU computing time (saving power and accelerating program execution), before programmers generate category files that can be executed on certain platforms, the programmer must first use the pre-reviewer on the PC for some pre-review work. The pre-reviewer will add some special marks or symbols to the category file. As a result, when these programs are executed on the target platform, the time for review on the target platform can be greatly reduced, and the process starts and executes can be accelerated. Therefore, the execution steps of Programs (spotlet and MIDlet) under j2's become because of the pre-audit relationship. When the execution is byte code, the work of the reviewer is reduced, therefore, the time between program loading and execution is shortened. The standard cldc instance and MIDP reference instance are attached with a pre-reviewer.
Java version Evolution
I believe that people familiar with the evolution history of Java have heard of it more or less. Java technology was not called Java at the beginning, but oak, and it was originally a product designed for embedded systems. In the future, due to the development of the Internet, many features of oak are suitable for use on the Internet (such as portability and small program code after compilation), because the trademark has been registered, therefore, the oak is renamed Java, and it will become a shining star on the Internet, and gradually become more and more mature with time. It also produces a lot of usage that is not originally expected.
Although Java has been used in many enterprise-level software, it is very suitable for embedded systems.
Although since the publication of Java 1.0, Java has been widely used in the development of desktop applications and applets, since Java 1.1, java has returned to its original path-embedded system applications. At that time, Sun Microsystems published embedded Java and personal Java (pjava) these two specifications. Embedded Java is designed for embedded devices with limited resources and no display devices. Personal Java is designed to connect to the Internet and have a display system (such as a color LCD) designed for consumer electronic devices. Then, the Java version evolved to Java 2. In order to clearly distinguish various Java applications, J2EE, j2se, and j23. The features of these three versions are described in detail. However, please remember that Java 2 divides Java applications into three parts, so that the development of Java programming language will not spread like a tree in Java 1.1, this will help you understand various Java applications, without causing a messy situation that will continue to grow. I would like to mention that, when personal Java was developed to version 1.2, it also adopted some security-related designs on the Java 2 platform.
Java 2 Micro Edition Concept
While designing its specifications, the basic principle of "Creating a single development system for a variety of devices is meaningless" is followed. In this case, all embedded devices are divided into two types: one is embedded devices with limited computing functions and limited power supply (such as PDAs and mobile phones ); the other is embedded devices with relatively better computing capability and ample power supply (such as air conditioners, refrigerators, and set-top boxes )). Because of these two types of embedded devices, Java introduces a concept called configuration, then, the embedded devices with limited computing capabilities and limited power are defined in the connected limited device configuration (cldc) specification, while the other device is standardized as the connected device configuration (CDC) specification. In other words, the concept of configuration is separated into two abstract types by all embedded devices.
In fact, here we can regard configuration as the specification for the two types of embedded devices by Using J2EE, these specifications define the specifications such as the computing capability, power supply capability, and memory size that these devices must meet at least, at the same time, a set of category libraries that can be used by Java programs executed on these devices are also set, the category library defined in these specifications is a subset of the java standard core category library, and extended category library that matches the characteristics of this type of device. For example, in cldc specifications, the core category Library Supported is Java. lang. * Java. io. * Java. util. *. The supported extended category library is Java. microedition. io. *. After the two main configuration types are distinguished, the concept of profile is defined by j2-based. Profile is the specification of the Architecture above configuration. The concept of profile is to better distinguish how Java programs on various embedded devices should be developed and what functions they should have. Therefore, the profile defines the extended category library that is very relevant to specific embedded devices, and how the user interfaces of Java programs on various embedded devices should be presented is defined in the profile. The extended category library defined in profile is created based on the core category library defined in the underlying configuration.
Java applications in Embedded Systems
Because Java was originally designed to be an embedded system, it is really amazing to use it on an embedded system. At the time-space conference that started to rise in Linux, there was a report on how embedded Linux and Java work together to create a win-win situation on the Internet, this is a white paper published by Randy rorden, a column writer at linuxdevices.com, titled "Cooperation between Java and embedded Linux 」. In this article, the author puts forward his views on the advantages of Embedded Linux and Java, and also puts forward the idea of the Java-Linux platform. Interested readers can go to the following websites to refer to relevant news and materials.
1. Cooperation White Paper between Java and embedded Linux
Http://www.ctech.com.tw/d-news/news/linux/89090208.asp;
2. Java and embedded Linux cooperation
Http://www.linuxdevices.com/news/NS5973673868.html;
3. Coming Java-Linux Integration
Http://www.linuxdevices.com/articles/AT7102892618.html;
Why use Java to write PDA applications?
From expectation to the coming of the mobile communication era, the prospects for the communications industry have become more promising. In addition to the main tool for achieving mobile communication-the more sophisticated the mobile phone month, more vendors have successively invested in the production and development of PDAs. Originally, the main PDA platforms were palmos, Windows CE, and EPOC. I don't know when a lot of companies started to invest in Embedded Linux R & D, including the @ vis operating system developed by the Chinese strategy itself, aihui technology also has its own embedded operating system, not to mention Chinese and Korean manufacturers.
These job platforms are several times more complex than PCs. Of course, the impact on general users is relatively small, but for program developers, it is really disappointing to see so many different program development platforms. If each platform has its own program writing and function library, you should learn at least five types of programming languages on the platform. Of course, it is good to concentrate only on one platform. But the program designer can't help but say, "Isn't it perfect if the software we write can be executed on these platforms without modifying the original code ?" For program developers, such a return on investment is of course the largest.
Developing programs on so many platforms is indeed a great challenge for programmers. If you want to focus all your time and effort on the availability of software, in most cases, we do not have that much time to write programs on various platforms. To solve this problem, generally, the programmer selects a cross-platform framework to achieve at least the source code level cross-platform (this can be done by using QT ). But what we will introduce in this article is the ultimate solution? Java, using the "write once, run anywhere" feature of Java, we can actually write the program once, it can be executed on any platform (the premise is that the vendor of the PDA must also implement the Java Virtual Machine of the platform ). Using Java for PDA programs has its disadvantages. The most widely known issue may be the issue of execution efficiency. Java has always been criticized for the issue of execution speed.
However, I believe that with the development of technology, there will be faster and more power-saving PDA dedicated CPU, so the efficiency problem can be ignored. What's more, Sun also used many methods to speed up the execution of Java on PDA (such as pre-approval) when designing j2s ).