[Author: Anonymous Copy from: Microcontroller and Embedded Systems Hits: 45 Update Time: 2005-2-24 article entry: fengjavax]
Summary: J2ME is a version of the Java 2 platform that uses a wide variety of consumer electronics and embedded devices. Java Card Technical Specifications Get Java applications can run on smart cards and smaller embedded devices.
This article describes the hardware platform and software architecture of J2ME and Java Card.
And how to develop J2ME and Java Card applications. The application of Java in the field of mobile communications has caused extensive attention. This article has been described in detail.
Keywords: Java embedded system Java card J2ME mobile communication
1 Java overview
Java is contemplated in 1991 by Sun James Gosling Patrick Naughton, Chis Warth, Ed Frank, and Mike Sherindan. It was officially launched in May 1995. The Java computing platform includes JVM (Java virtual machine) and Java API (Java App Programming Interface). JVM is an abstract computer that runs above the operating system, which can perform Java byte lines above it, allowing Java applications to perform smoothly on existing platforms. Java API and Java's function class library is divided into basic core class libraries and various extensions libraries.
On December 8, 1998, Sun's latest version of JDK (Java Software Development Kit) was officially released, and Sun's upgraded version, but also a perfect Java platform.
Java 2 defines the core technology of the Java Enterprise Platform, including 15 core APIs. These 15 core APIs constitute the soul of Java 2 technology, including Applet, AWT, Beans, IO, LANG, MATH, NET, RMI, Security, SQL, Text, Util, Accessibility, Swing, and Corba. Compared with past JDK, the Java 2 platform has many advantages, such as more flexible security patterns, better performance, interoperability of other enterprise systems, improved globalization, and better cross-platform Sex.
Java 2 can be divided into four versions depending on the software, hardware requirements. J2EE (Java 2 Platform, Enterprise Edition) is used for enterprise server-side applications; J2SE (Java 2 Platform, Standard Edition) is used in applications developed on personal computers; J2ME (Java 2 Platform, Micro Edition) is used for information appliance Application development on devices such as limited resources; Java Card Platform is used for applications on smart cards.
The Java program language is designed for embedded devices - set-top box equipment. Now Java has returned to the embedded system development field with J2ME and Java Card Platform.
2 Java card (1) Java card Introduction Java card is the smallest subset in the Java platform, as well as a special smart card. Smart card is a card embedded in computer chip, widely used in communication, transportation, finance, securities and insurance. Smart cards are divided into two categories: one is a memory card, and the other is a microprocessor card. The memory card is only used for memory data. Microprocessor card has data processing features: it has its own CPU, I / O port, memory and operating system, which can be seen as a microcomputer; install and run small applications, through serial communication interface Communication with external communication. ISO (International Standards Organization) has developed an international standard ISO 7816 for smart cards. The main factor affecting smart card promotion is that it is not open enough, and the application development of cards produced by different card manufacturers has no unified standards. In order to solve this problem, the industry proposes a smart card-Java card that runs Java programs, and develops technical specifications for Java cards, including Java Card VM (Java Card Virtual Machines), and API details. Java Card VM is located on the operating system of the smart card, shields different smart card hardware and operating systems with a general programming language and system interface. The framework of the Java card defines the API used by the application developer. The Java card application is called Applet, and each applet is identified by a unique AID (application identifier). (2) Java card The minimum requirements for hardware 512 B RAM: mainly used to store the stack of the application running and the I / O buffer. 24 KB ROM: It is mainly used to store program code and system runtime system. 8 KB EEPROM: Mainly used to store Applets and stacks of Java cards. 8-bit processor: 8-bit processor is the minimum requirement of the Java card. (3) The Java card software architecture JAVA card software architecture is shown in Figure 1. The bottom Card OS (operating system) and Native functions are not in the operating system of personal computers, responsible for the processing of low-level processing. Java Card VM is located on the Card OS and Native Functions, concealed the different technologies of the underlying smart card, realizing the unity of the card interface and the unity of programming languages. Java Card Framework (Java Card Framework) defines a set of APIs for developers, primarily responsible for running Java card applets and providing the environment required for Applet. Card OS, Java Card VM, and Java Card Framework together form a JCRE (Java card running environment). Industry Specific Extensions is the class provided by the service to enable companies to provide their own service programs. For example, if this card is a SIM (user identification module) card of the GSM network, then this layer is the interface class required by the SIM card. (4) Java Card API Java Card's version 2.1 includes four packages: javacard.lang package, Javacard.Frame Work Package, Javacard.Security Package, and Javacardx.cryp to package. Javacard.Lang Package provides important classes in the Java program language, such as all root Object classes for all Java classes. Javacard.frame Work Package is the core package of Java Card API, which provides the basic class and tools for implementing Java Card Applet. Where ISO7816 abstract interface provides constant values used by ISO7816. PIN (Personal Identity Number) Abstract Interface Makes its subclasses to verify that the PIN is legal.
The Shareable abstract interface makes different applets to communicate with each other. The AID class makes JCREs to identify Applets through an AID table. The APDU class receives the command and the state of the transmission terminal and the return applet running result and status by managing a buffer. The Applet class is the root class of all Java Card Applets, which manages the life cycle of the Java Card Applet. JCSYSTEM class management applet and Java Card system resources, such as AID and transactions. Ownerpin class management card holder's PIN, and provides a related verification and update. The UTIL class provides the common tools in the development. Javacard.Security Package is responsible for providing a security mechanism, including the Key abstract interface, the KeyBuilde class, and the MessageDisest class. Javacardx.cryp to package contains abstract interfaces and classes with encryption and security. (5) The lifecycle of the Java card application is started from the operating system, JVM, API library, and optional applets to be written to the ROM of the Java card. Prior to official use, the Java card should be initialized (written to the manufacturer and distributor name on the card) and personalization (written to the key on the card). Then the user can purchase and use the Java card, and of course cooperation with the card reader. The life cycle of the applet begins with the installed and registered to the Java card system, and ends when deleted from the system registry, activated when selected. The Java card app can be compiled with a general Java compiler. However, because smart cards have only limited memory resources and computing functions, the application development on the Java card is very different from ordinary Java program, and many of the Java language features cannot be used in the development of Java card applications. The application development of the Java card (under Windows System) The process is as follows: 1 Install the JDK and Java Card 2.1.1.1 Development Kit; 2 Set the environment variable; 3 Edit the Java source code, you can use any Java code editing tool; 4 compile Java Source Code, compile the Java source code with the Java compiler, generate the class file; 5 Generate a CAP file, you can't run the class file directly on the Java card, you must use the Java card converter (converter), convert the class file to a CAP file; 6 installation Applet, install the CAP file to the Java card with a PC and a card reader connected to the Java card. Figure 2 is a schematic diagram of a Java card application development process. (6) Java card Application SIM (User Identity Module) in the field of mobile communication is used as a smart card containing large-scale integrated circuits, which is currently used for GSM phones. The initial SIM card is mainly used to store some individual identity authentication and identification information, such as IMSI, authentication keys, and the like. The SIM card cannot be commanded to the phone. In 1998, ETSI (European Telecommunications Standardization Committee) developed the technical specifications of STK card (SIM application toolbox technology), which greatly enhanced the SIM card's ability. The STK card can be installed on the STK card, you can send a command to your phone, such as building a new menu on your phone. The SIM card can also send and receive short messages even launched a call. This allows the client's software to run the client on the SIM card, interacting with the server, while providing a friendly interface through the menu. Although STK standardizes the use of SIM cards, each manufacturer still uses its own development tool as a self-selected chip mask, so it is necessary to introduce an open SIM card open platform. ETSI has added the contents of Java Card in its agreement. The GSM SIM card uses Java Card API to ensure open SIM development while ensuring security, allowing STK to run on different manufacturers' SIM cards.
During the development, software developers can develop an open development tool to develop SIM card applications with Java compatible. ETSI's protocol GSM 03.19 is the technical standard of the STK Java card, which specifies the architecture of the STK JAVA card. The bottom is the JCRE and GSM file system. The above is the GSM framework, providing some APIs for Applet accessing the GSM file system. Above the GSM framework is the Sim Toolkit framework, responsible for the trigger, registration, installation, and uninstall of Applet, processing of the active command, the security management of Applet. 3 J2ME (1) J2ME Introduction J2ME is designed to use Java programming languages for Sun for resources, using Java programming languages, such as smart cards, mobile phones, PDAs, TV set-top boxes, etc. The J2ME platform is built on the Java programming language that provides the greatest features for devices with limited resources. J2ME currently has two configuration layers. One is "Connected Device Configuration" CDC (Connected Device Configuration), which uses a typical Java virtual machine technology. This full-featured virtual machine contains all functions of a virtual machine on a desktop system that apply to devices with at least a few megabyte memory. Its goals are high-grade consumer electronics and embedded devices such as intelligent communications, advanced "intelligent" pagers, smart personal digital assistants (PDAs), and interactive digital TV set-top boxes. For wireless devices and other indifferent devices, J2ME adopts "Connected Limited Device Configuration" technology using "Connected Limited Device Configuration" technology. (2) J2ME The minimum requirements for hardware CDC and CLDC have different requirements for hardware platforms: CDC-32-bit microprocessors, greater than 2MB of memory. CLDC-16 or 32-bit processor, greater than 128KB memory. (3) J2ME Software Architecture Figure 3 shows the J2ME software architecture. Java Virtual Machine Layer is an implementation of the Java virtual machine, which is customized for host operating systems for specific devices, and supports a specific J2ME. The JVM configured by the CDC is a CVM (C virtual machine). The JVM configured by CLDC is KVM (K virtual machine). The Configuration Layer defines the minimum set of Java class libraries available on the Java virtual machine feature and specific categories. Some programs say a configuration defines the commonality of the Java platform feature and libraries, developers can assume that these feature and libraries are available on all devices belonging to a particular class. The Profile Layer defines the minimum set of applications programming interfaces available on a particular family of devices. The frame is implemented above a specific configuration, adding a configuration file that applies to a specific specification on the configuration layer, such as the MIDP is the configuration file for the mobile terminal. The application is written for a particular framework, so that one device can support multiple frames on any device that supports the framework. (4) J2ME API CDC provides the smallest API set required for full compatible Java 2 virtual machines. This API set includes all APIs defined for CDC and APIs for file I / O, network connection, advanced completeness, object sequences.
Where java.io supports system input and output, Java Lang Java provides programming language basic classes, java.lang.ref includes some special reference classes, java.lang.reflect provides support for reflection, Java.math supports mathematical operation, Java .NET provides classes and tools for network connections, Java.Security provides full support, Java.Security.cert provides certificate support, Java.Text provides text processing classes, Java.util includes a variety of practical uses, date and time support. Tools, java.util.jar provides JAR file support, Java.util.zip provides ZIP file support, supports the Javax.microedition class connection. Since the MIDP / CLDC API will run on a limited performance device, some of Java's features are canceled or modified. Java.lang, Java.io, Java.util package is a subset of standard classes in the J2SE package. Javax.microEdition.IO package provides support for network connection, and the main object in javax.microedition.IO is the Connector class. This class can be forced to convert to a different connection type, such as HTTPConnection. Javax.microedition.lcdui provides classes for defining the MIDlet user interface. Javax.microEdition.rms package is used to implement a temporary storage database on the device, and of course the storage of the database and the performance of the information is limited by the device. The javax.microedition.midlet contains classes with MIDlet. The MIDlet class performs the lifecycle of the MIDlet, and provides the getAppProperty method to get information in the application properties. Application Properties is set in the JAD (Java Application Descriptor) file. (5) The Java card applies CLDC and MIDP in the mobile communications field to create a complete environment for creating mobile phone applications. The core of the MID frame is a MIDlet application. All application MIDLETs inherit the MIDlet class to allow application management software to control the MIDlet, retrieve properties, and notify status changes from the application descriptor. The MIDLET class provides an API for calling, pause, restarting, and terminating the MIDlet application. Application Management Software can manage multiple MIDlet activities in the runtime environment. In addition, MIDlet can initiate some status changes and notify these changes to the application management software. Mobile phone J2ME MIDP applications include user interface development, database program development, and network program development. The javax.microedition.lcdui package includes various classes for user interface development. The root class of the user interface is Display, all user interface classes are displayable objects displayed in the Display, the Display object is the stage of other object demonstrations, the application moral needs to get a reference to the Display object, and then put the scene object Enter the presentation stage. MIDP provides two Spring Scenes, SCREEN and Canvas. Screen's subclasses include Alert, Form, List, and TextBox. The COMMAND class defines the user's input information in javax.microedition.lcdui, which defines the user's input information, and the method of combining the SCREEN object and the Command object is defined in the Display class, so that the application can respond to the user's input. The objects that can be used in the Screen scenario include Alert, Form (Form), List (Options List), and TextBox (text box).